You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Peter Pilsl <pi...@goldfisch.at> on 2001/10/24 00:48:44 UTC

namespace-troubles

I run into deep namespacetroubles I understand onyl vaguely and I cant workaround:

I have a script running under mod_perl that is called via two domains.

www1.domain.at/  
www2.domain.at/sub/

both of the above addresses lead to the very same script (its the same
file on the disk, not a copy). When I call the first adress all is
working fine, but as soon as I call the second adress I get a
server-error.  Restarting apache and I try the second first: running
fine, but as soon as I call the first: server-error.

The log reveals:

Undefined subroutine &Apache::ROOTwww1_2domain_2eat::main called at 
/data/public/stage2/fetch.pl line 9.

or

Undefined subroutine 
&Apache::ROOTwww2_2edomain_2eat::editeinstieg::main called at 
/data/public/stage2/fetch.pl line 9.

my script is structured like that:
----fetch.pl:
require fetch.lib.pl
main();
-----

---fetch.lib.pl:
sub main{

do everthing here

}
1;
----

As far I can see, the second call does not load the lib anymore, cause
it was already loaded on the first call. Unfortunately it was loaded
to a different namespace, so the script doesnt find it.

What can I do ? I need this different domains, cause the script-action
depends on the calling domain.

The reason why I splitted in script/lib is a document at apache.org
that recommends this to avoid a nested-sub-problem under mod_perl.

I wonder if providing the lib-file as module (use instead of require)
would be a solution, but I guess not.  Can the above problem occure
with modules too ? If two scripts call the same module, is it only
loaded on the first call and the second script fails ??

thnx,
peter


-- 
mag. peter pilsl

phone: +43 676 3574035
fax  : +43 676 3546512
email: pilsl@goldfisch.at
sms  : pilsl@max.mail.at

pgp-key available

Re: namespace-troubles

Posted by Perrin Harkins <pe...@elem.com>.
Sorry if I came off sounding harsh.  I spend a lot of my personal time
answering newbie questions on this list, and it bothers me when people
say that newbies don't get helped here.  They generally get a lot of
help here.

If someone says "it's in the guide" and you can't find it, ask for a
link to the relevant section.  If you read that section and still don't
get it, ask more questions.  Sending people links to the proper docs in
response to questions when possible is a simple matter of efficiency.

- Perrin

Re: namespace-troubles

Posted by John Michael <jo...@acadiacom.net>.
Not to beat a dead horse, because this subject is well over.
Sorry, if I offended anyone.
Anyway,  I always get and often see others get:

"You obviously have not read the documentation answer."

And wanted to put in my perspective being new to this list and trying to
learn mod_perl.

I love perl and have more than 15 books on the subject.  Here is my list.
Programming Perl
Programming the Perl DBI
Writing Apache Modules
Object Oriented Perl => Damian Conway
Advanced Perl Programming
Perl Cookbook
Perl for System Administration
Regular Expressions
Network Programming with Perl =>Lincoln Stein's new book
Perl in a Nutshell
Web Client Programming
Effective Perl Programming
Mastering Aogorithms with Perl
CGI Programming
MySQL & mSWL
Official Guide to Programming with CGI.pm
Learning Perl
Programming Web Graphics
Perl Core Language
Plus the APache Book
and some books that cover Perl and PHP on MySql

I think your name, Parrin is on or around those books somewhere.  I have
seen it before.
I know I have seen Randalls several times.  He is famous for the answer:
"Stop limiting the limits." whenever you ask a question about limits on
Apache.  The answer doesn't tell you the answer to your problem.  I know now
not to use it though.

I also have several links to perl sources and yes, the guide.
I have read most of these and or something out of them and some of them more
than once.
I have also read the parts of the guide more than once.
I have been doing this for around 3 or 4 years I guess.
I tried to tackle mod_perl about a year ago, but with no success and am
doing it again with moderate success.
I think it is easy when you know something to write out an answer that you
think everyone else will know.

For instance, Once I had a file locking problem and some one said:
Use a semephore file.
A day later, I finally found out what a semephore file was.
Often when I get an answer, I usually have to go back to the books to find
out what it means or how to use it.
The turnaround on problems can be days, trying every combination under the
sun to see if it works.

When I got the previous answer that said: Don't use -w and to use PerlWarn
On, it took me about 30 minutes to figure out where to put it.  I put it in
the startup.pl file.  Still hoping that was the right place.

Still, when you run into problems with Mod_perl, there are really only a
couple of places to look.
And just because you have read something, doesn't mean that when a problem
arises, the answer will hit you.
I often find myself reading old material with more knowledge than when i
previously read it and now understand things I didn't have a clue about
before.
Even though I have read and used a lot of this information, I can tell by
the answers and talks you have on the list, that I am still pretty much an
amateur.

I think when people ask questions, they have not always just opened up an
email and sent it out without thought.  There is a great fear in that.  You
don't know what kind of answer you will get, whether you will understand it
and have to ask another seemingly stupid question, or get flammed for doing
so and never be able to ask a question again.

I usually think about it for a couple of hours, try every combination I can
think of, and look in every book I think will have something to do with it
before tucking my tale and asking a list.
Yes, sometimes I will ask before spending the time if I feel I don't have
the time to try and find it myself, or have just spent 3 hours trying to
solve another problem.

Obviously, there are either too many sources or not enough. :)  I can't
tell.  Too many places to look sometimes and not enough others.

Sometimes it would be nice to be able to ask stupid questions and get
answers instead of clever indirect put downs.  Maybe, I just read too much
into the emails because of my own insecurities with the language.  IT is
hard to get a feel for text based conversation.

Anyway, I just wanted to put in my two cents and am thinking I might just
get flammed for this as well.
Should I send it?  Sometimes I get this far on emails and just delete them.

Cya and thanks
John Michael


> John Michael wrote:
>
> > I don't know if this will help.  I know very litlle about mod perl, but
most
> > of the people on this list don't seem to answer questions from
beginners.
>
>
> Hmmm.  You asked some questions that made it sound like you hadn't read
> the documentation, and you stil got 3 answers in 24 hours.  One thing
> you should consider is that not everyone here is in the same time zone.
>
>
> > I think you might try adding:
> > use subs qw(main);
> > in the top of your script.
> > or instead of
> > main() use &main()
>
>
> That's probably not it.  The difference between mail() and &main() is
> that &main() circumvents prototypes, as documented in the perlsub man
page.
>
>
> > If that doesn't work, you will probably need to make the lib a package
and
> > import it into your fetch.pl program.
>
>
> That probably *is* the answer, and a good programming practice for any
> perl project.
>
>
> > Does anyone know of a news group that answers mod perl questions?
>
>
> There are lots of places that will answer mod_perl questions
> (http://perlmonks.org/ for example), but none as good as this list.
>
> - Perrin
>


Re: namespace-troubles

Posted by Perrin Harkins <pe...@elem.com>.
John Michael wrote:

> I don't know if this will help.  I know very litlle about mod perl, but most
> of the people on this list don't seem to answer questions from beginners.


Hmmm.  You asked some questions that made it sound like you hadn't read 
the documentation, and you stil got 3 answers in 24 hours.  One thing 
you should consider is that not everyone here is in the same time zone.


> I think you might try adding:
> use subs qw(main);
> in the top of your script.
> or instead of
> main() use &main()


That's probably not it.  The difference between mail() and &main() is 
that &main() circumvents prototypes, as documented in the perlsub man page.


> If that doesn't work, you will probably need to make the lib a package and
> import it into your fetch.pl program.


That probably *is* the answer, and a good programming practice for any 
perl project.


> Does anyone know of a news group that answers mod perl questions?


There are lots of places that will answer mod_perl questions 
(http://perlmonks.org/ for example), but none as good as this list.

- Perrin


Re: namespace-troubles

Posted by Rafiq Ismail <ra...@codix.net>.

> > working fine, but as soon as I call the second adress I get a
> > server-error.  Restarting apache and I try the second first: running
> > fine, but as soon as I call the first: server-error.
> > Undefined subroutine &Apache::ROOTwww1_2domain_2eat::main called at

I'm curious why you're you're using two namespaces for identical scripts
and files?  If there is no differentiation between the scripts why have it
in the namespace?  Just use the same "PerlRequire /your/file"  in both
your vhost confs.

> > Undefined subroutine
> > &Apache::ROOTwww2_2edomain_2eat::editeinstieg::main called at
> > /data/public/stage2/fetch.pl line 9.

It's probably neater to turn your lib.pl into a package and require the
package.  Do "perldoc -f require" and "perldoc -f use" and then decide
whether your really need to require it.

> >
> > What can I do ? I need this different domains, cause the script-action
> > depends on the calling domain.
Well you don't want to be fetching it from your namespace do you!!! 
Use your environment variables.


-- 
Rafiq Ismail

Software Engineer and Systems Administrator
http://www.codix.net


"All the best people in life seem to like Linux." - Steve Wozniak





Re: namespace-troubles

Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
Hi there,

On Tue, 23 Oct 2001, John Michael wrote:

> most of the people on this list don't seem to answer questions from beginners.
[snip]
> Does anyone know of a news group that answers mod perl questions?

The mod_perl mailing list is the proper forum for such questions, but
one of the troubles is that although there are truckloads of documentation
which already contain a lot of the answers to questions which are
posed oftentimes on the list, people seem studiously to avoid reading it.

Please see

http://perl.apache.org/email-etiquette.html

(OK, it's new, but I just thought I'd mention it... :)

73,
Ged.


Re: namespace-troubles

Posted by John Michael <jo...@acadiacom.net>.
I don't know if this will help.  I know very litlle about mod perl, but most
of the people on this list don't seem to answer questions from beginners.
I think you might try adding:
use subs qw(main);
in the top of your script.
or instead of
main() use &main()
There are situations where you can't use main() without the & and I think it
has to do with predeclaring the sub which use subs will remedy.  let me know
if this helps.
If that doesn't work, you will probably need to make the lib a package and
import it into your fetch.pl program.
Kindof new to that as well and havn't experimented much with it.

Does anyone know of a news group that answers mod perl questions?
cya
jm


----- Original Message -----
From: "Peter Pilsl" <pi...@goldfisch.at>
To: <mo...@apache.org>
Sent: Tuesday, October 23, 2001 5:48 PM
Subject: namespace-troubles


> I run into deep namespacetroubles I understand onyl vaguely and I cant
workaround:
>
> I have a script running under mod_perl that is called via two domains.
>
> www1.domain.at/
> www2.domain.at/sub/
>
> both of the above addresses lead to the very same script (its the same
> file on the disk, not a copy). When I call the first adress all is
> working fine, but as soon as I call the second adress I get a
> server-error.  Restarting apache and I try the second first: running
> fine, but as soon as I call the first: server-error.
>
> The log reveals:
>
> Undefined subroutine &Apache::ROOTwww1_2domain_2eat::main called at
> /data/public/stage2/fetch.pl line 9.
>
> or
>
> Undefined subroutine
> &Apache::ROOTwww2_2edomain_2eat::editeinstieg::main called at
> /data/public/stage2/fetch.pl line 9.
>
> my script is structured like that:
> ----fetch.pl:
> require fetch.lib.pl
> main();
> -----
>
> ---fetch.lib.pl:
> sub main{
>
> do everthing here
>
> }
> 1;
> ----
>
> As far I can see, the second call does not load the lib anymore, cause
> it was already loaded on the first call. Unfortunately it was loaded
> to a different namespace, so the script doesnt find it.
>
> What can I do ? I need this different domains, cause the script-action
> depends on the calling domain.
>
> The reason why I splitted in script/lib is a document at apache.org
> that recommends this to avoid a nested-sub-problem under mod_perl.
>
> I wonder if providing the lib-file as module (use instead of require)
> would be a solution, but I guess not.  Can the above problem occure
> with modules too ? If two scripts call the same module, is it only
> loaded on the first call and the second script fails ??
>
> thnx,
> peter
>
>
> --
> mag. peter pilsl
>
> phone: +43 676 3574035
> fax  : +43 676 3546512
> email: pilsl@goldfisch.at
> sms  : pilsl@max.mail.at
>
> pgp-key available


Re: namespace-troubles

Posted by Stas Bekman <st...@stason.org>.
> Undefined subroutine &Apache::ROOTwww1_2domain_2eat::main called at 
> /data/public/stage2/fetch.pl line 9.


it's all in the guide :)

http://perl.apache.org/guide/porting.html#Name_collisions_with_Modules_and


_____________________________________________________________________
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/


Re: namespace-troubles

Posted by ryc <ii...@binary.net>.
If you make the following change (putting fetch into a package..)

fetch.lib.pl --
package fetch;
sub main { ... }
--

and then

fetch.pl --
require fetch.lib.pl;
foo::main();
--

This should solve your problem.

ryan

----- Original Message -----
From: "Peter Pilsl" <pi...@goldfisch.at>
To: <mo...@apache.org>
Sent: Tuesday, October 23, 2001 5:48 PM
Subject: namespace-troubles


> I run into deep namespacetroubles I understand onyl vaguely and I cant
workaround:
>
> I have a script running under mod_perl that is called via two domains.
>
> www1.domain.at/
> www2.domain.at/sub/
>
> both of the above addresses lead to the very same script (its the same
> file on the disk, not a copy). When I call the first adress all is
> working fine, but as soon as I call the second adress I get a
> server-error.  Restarting apache and I try the second first: running
> fine, but as soon as I call the first: server-error.
>
> The log reveals:
>
> Undefined subroutine &Apache::ROOTwww1_2domain_2eat::main called at
> /data/public/stage2/fetch.pl line 9.
>
> or
>
> Undefined subroutine
> &Apache::ROOTwww2_2edomain_2eat::editeinstieg::main called at
> /data/public/stage2/fetch.pl line 9.
>
> my script is structured like that:
> ----fetch.pl:
> require fetch.lib.pl
> main();
> -----
>
> ---fetch.lib.pl:
> sub main{
>
> do everthing here
>
> }
> 1;
> ----
>
> As far I can see, the second call does not load the lib anymore, cause
> it was already loaded on the first call. Unfortunately it was loaded
> to a different namespace, so the script doesnt find it.
>
> What can I do ? I need this different domains, cause the script-action
> depends on the calling domain.
>
> The reason why I splitted in script/lib is a document at apache.org
> that recommends this to avoid a nested-sub-problem under mod_perl.
>
> I wonder if providing the lib-file as module (use instead of require)
> would be a solution, but I guess not.  Can the above problem occure
> with modules too ? If two scripts call the same module, is it only
> loaded on the first call and the second script fails ??
>
> thnx,
> peter
>
>
> --
> mag. peter pilsl
>
> phone: +43 676 3574035
> fax  : +43 676 3546512
> email: pilsl@goldfisch.at
> sms  : pilsl@max.mail.at
>
> pgp-key available
>


Re: namespace-troubles

Posted by David Young <dy...@nettonettech.com>.
Hey, it just so happens I was reading-up on the voluminous mod_perl
documentation out there, and it would appear I stumbled across the answer to
your problem:

http://perl.apache.org/dist/mod_perl_traps.html#Perl_Modules_and_Extensions

> From: Peter Pilsl <pi...@goldfisch.at>
> Date: Wed, 24 Oct 2001 00:48:44 +0200
> To: modperl@apache.org
> Subject: namespace-troubles
> 
> I run into deep namespacetroubles I understand onyl vaguely and I cant
> workaround:
> 
> I have a script running under mod_perl that is called via two domains.
> 
> www1.domain.at/  
> www2.domain.at/sub/
> 
> both of the above addresses lead to the very same script (its the same
> file on the disk, not a copy). When I call the first adress all is
> working fine, but as soon as I call the second adress I get a
> server-error.  Restarting apache and I try the second first: running
> fine, but as soon as I call the first: server-error.
> 
> The log reveals:
> 
> Undefined subroutine &Apache::ROOTwww1_2domain_2eat::main called at
> /data/public/stage2/fetch.pl line 9.
> 
> or
> 
> Undefined subroutine
> &Apache::ROOTwww2_2edomain_2eat::editeinstieg::main called at
> /data/public/stage2/fetch.pl line 9.
> 
> my script is structured like that:
> ----fetch.pl:
> require fetch.lib.pl
> main();
> -----
> 
> ---fetch.lib.pl:
> sub main{
> 
> do everthing here
> 
> }
> 1;
> ----
> 
> As far I can see, the second call does not load the lib anymore, cause
> it was already loaded on the first call. Unfortunately it was loaded
> to a different namespace, so the script doesnt find it.
> 
> What can I do ? I need this different domains, cause the script-action
> depends on the calling domain.
> 
> The reason why I splitted in script/lib is a document at apache.org
> that recommends this to avoid a nested-sub-problem under mod_perl.
> 
> I wonder if providing the lib-file as module (use instead of require)
> would be a solution, but I guess not.  Can the above problem occure
> with modules too ? If two scripts call the same module, is it only
> loaded on the first call and the second script fails ??
> 
> thnx,
> peter
> 
> 
> -- 
> mag. peter pilsl
> 
> phone: +43 676 3574035
> fax  : +43 676 3546512
> email: pilsl@goldfisch.at
> sms  : pilsl@max.mail.at
> 
> pgp-key available
>