You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Thomas Hilbig <th...@yahoo.com> on 2002/11/15 22:53:13 UTC

Namespace problem

I am having a namespace problem that is a slight twist
to that described in the 1.0 docs
http://perl.apache.org/docs/1.0/guide/porting.html#Name_collisions_with_Modules_and_libs

My problem is even simpler, but worse.  If I have two
CGI programs using the same required script. 
Initially one works without any problems.  Then if I
call up the other script, each time I get an error
saying the subroutine cannot be found.  Refresh the
browser and it works, but then the first one starts to
give an error;

Error message: 
          Undefined subroutine
&ModPerl::ROOT::ModPerl::Registry::home_httpd_qx_2dbin_gdtest1::goodDay

called at /home/httpd/qx-bin/gdtest1 line 7. 

This has to be something simple because I don't get
the error with normal Library components.   What am I
missing here??

Here is the package, and both CGI scripts that use it.
Thanks for any help,
Tom

------ commontest.pl  ----------
#!/usr/local/bin/perl
# Common Functions that will be 'required' by Perl CGI
scripts

CONFIG: {
   package commontest ;
}

sub goodDay {
  package commontest ;
  print "<H1>Good Day Billy</H1>\n" ;
}

1;  

------ gdtest1 (First CGI script that uses the
package----------------
#!/usr/local/bin/perl

require "/usr/lib/perl5/site_perl/commontest.pl" ; 
print "Content-Type: text/html;
charset=ISO-8859-1\n\n" ;
print "<head><title>Test
1</title></head><body><H1>Test 1</H1>\n" ;

&goodDay ;

print "</body><html>\n" ;
exit ;

------ gdtest2  (Second  CGI script that uses the
package----------------
#!/usr/local/bin/perl

require "/usr/lib/perl5/site_perl/commontest.pl" ; 
print "Content-Type: text/html;
charset=ISO-8859-1\n\n" ;
print "<head><title>Test
2</title></head><body><H1>Test 2</H1>\n" ;

&goodDay ;

print "</body><html>\n" ;
exit ;


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com

Re: Namespace problem

Posted by Stas Bekman <st...@stason.org>.
Thomas Hilbig wrote:
> I am having a namespace problem that is a slight twist
> to that described in the 1.0 docs
> http://perl.apache.org/docs/1.0/guide/porting.html#Name_collisions_with_Modules_and_libs
> 
> My problem is even simpler, but worse.  If I have two
> CGI programs using the same required script. 
> Initially one works without any problems.  Then if I
> call up the other script, each time I get an error
> saying the subroutine cannot be found.  Refresh the
> browser and it works, but then the first one starts to
> give an error;
> 
> Error message: 
>           Undefined subroutine
> &ModPerl::ROOT::ModPerl::Registry::home_httpd_qx_2dbin_gdtest1::goodDay
> 
> called at /home/httpd/qx-bin/gdtest1 line 7. 

It's not any different, please read that section again. You must be 
hitting different children hence you see the problem with the first script.


-- 


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/