You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jeff Pang <pa...@earthlink.net> on 2006/11/19 04:46:13 UTC

Undefined subroutine in the included templates

Hello,lists,

I have a strange problem for my modperl programs which are run under Apache::Registry (MP1).
In my script I require some templates like:

require "templates/groupshow_head.tpl";

Here groupshow_head.tpl is a template file which primarily print chunk of HTML codes in subroutine,like:

sub print_groupshow_head
{
    print <<HTML_EOF;
    html codes here
HTML_EOF
}

Then in my main scripts I called these subroutines directly,like:

require "templates/groupshow_head.tpl";
print_groupshow_head();


But the problem is many time I can't get the correct result,and get this error in error_log:

[error] Undefined subroutine &Apache::ROOT::groups::listMembers_2epl::print_groupshow_head called at /home/apache1.3/modperl/listMembers.pl line 26.\n

Ok,then I restart Apache,thing become fine.

Can you tell me why this happen?Thank you.





--
Books below translated by me to Chinese.
Practical mod_perl: http://home.earthlink.net/~pangj/mod_perl/
Squid the Definitive Guide: http://home.earthlink.net/~pangj/squid/

Re: Undefined subroutine in the included templates

Posted by Perrin Harkins <pe...@elem.com>.
Jeff Pang wrote:
> [error] Undefined subroutine &Apache::ROOT::groups::listMembers_2epl::print_groupshow_head called at /home/apache1.3/modperl/listMembers.pl line 26.\n

You're running into this problem:
http://perl.apache.org/docs/1.0/guide/porting.html#Name_collisions_with_Modules_and_libs

The best solution is to put your subs into a namespace with a package 
declaration.

- Perrin