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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
> sms  : [EMAIL PROTECTED]
>
> pgp-key available
>

Reply via email to