Code:
sub pre_load { # -------------------------------------------------------------------
# Pre loads all scripts using Apache::RegistryLoader.
#
my $cfg = new Dbsql::Config;
my $url = $cfg->{db_cgi_url};
my ($base_url) = $url =~ m,^https?://[^/]+(.*),;
$base_url =~ s,/$,,;
my $path = $cfg->{admin_root_path};
$path =~ s,/admin/?$,,;
# Preload all our cgi scripts.
require Apache::RegistryLoader;
my $r = Apache::RegistryLoader->new;
opendir (DIR, "$path") or die "Unable to open $path ($!)";
my @scripts = grep { /\.cgi/ } readdir (DIR);
closedir (DIR);
opendir (DIR, "$path/admin") or die "Unable to open admin: $path/admin";
my @admin = grep { /\.cgi/ } readdir (DIR);
closedir (DIR);
# Turn on warnings to check that the scripts are ok.
local $^W = 1;
print STDERR "Preloading DBMan SQL scripts into mod_perl:\n\t";
foreach my $script (@scripts) {
print STDERR ". ";
$r->handler ($base_url . '/' . $script, $path .'/' . $script);
}
foreach my $script (@admin) {
print STDERR ". ";
$r->handler ($base_url . '/admin/' . $script, $path .'/admin/' . $script);
}
print STDERR "\nAll scripts compiled and loaded ok!\n\n";
}
http://www.bookings.org