On Thu, 2003-08-28 at 16:09, Tim Edwards wrote:
> I in the process of switching my scripts over to Mod Perl.
> 
> I decide since Mod Perl doesn't like Sub routine in the the main program I'd 
> export make Modules out of the more come ones.

Just to be clear, mod_perl has no problem with subroutines inside of the
main program.  Apache::Registry has issues with it but only if you are
using lexically scoped variables and declaring them outside of your subs
rather than passing all parameters to the subs.

In other words, don't do this with Apache::Registry:

my $cgi = CGI->new();

foo();

sub foo {
    my $input = $cgi->param('input');
}

That breaks because $cgi is not passed to foo(), so it becomes a closure
and will always be the same as it was the first time the script was run.

> Error:
> 
> Undefined subroutine &main::CISCHeader called at /var/www/perl/test.pl line 
> 5.
> 
> Here the Module Located in the ModPerl Directory under the a directory 
> listed int eh @inc:
> 
> package ModPerl::Rules1;
> 
> sub CISCHeader {
>    print "Content-type: text/plain\n\n";
>    print "mod_perl rules!\n";
>    return 1;
> }
> 1;
> 
> The Script:
> 
> #!/usr/bin/perl -w
> use strict;
> use ModPerl::Rules1;
> 
> CISCHeader();

Your module doesn't export the CISCHeader sub, so you have to call it
with the full name: ModPerl::Rules1::CISCHeader().  If this doesn't make
sense to you, you should read the "perlmod" man page that explains how
modules and packages work.

- Perrin


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html

Reply via email to