
kencl
User
Aug 16, 2003, 5:04 PM
Post #1 of 4
(21631 views)
|
What package is the main script in?
|
Can't Post
|
|
Hi Folks, Does anyone know what the package name is for a script running under Apache::Registry? I'm trying to access a subroutine in a custom perl module I've written. In simple terms, here's what I'm doing: Main Script our %G; $G{'dirs'}{'template'} = '/home/username/safe/templates/'; use Custom::Common; # contains sub Error use Custom::Template; # contains sub Load_Template my %args = (template => 'template_filename.html'); my $template; unless($template = &Load_Template(\%args)) { # print error message here } package Custom::Template sub Load_Template { my $arg_ref = shift; # test access to template file my $file = $main::G{'dirs'}{'template'} . $arg_ref->{'template'}; unless (-e $file) { &main::Error({ msg => "Load_Template: requested template file ($file) does not exist.", actions => 'collect_all log_msg email_developer' }); return 0; } } What's happening is that the reference to main:: isn't correct, so the path to $file is not correct. Since the path is not correct, the -e file test returns false. The call to &main::Error is unable to find sub Error and leaves this message in the error log: "Undefined subroutine &main::Error called at /home/username/safe/pm/Custom/Template.pm line 32" sub Error is exported into package main properly, and this system works fine when run as a CGI script. I'm guessing that the problem is the reference to main::, when in fact it's probably the Apache handler subroutine which is in main and my "main" script is in some other package. Any suggestions? Thanks. >> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!
(This post was edited by kencl on Aug 16, 2003, 5:50 PM)
|