You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Henrik Tougaard <ht...@foa.dk> on 2001/07/30 10:07:59 UTC

Annoying use of "no lib" in Apache::ASP

I have some code i my global.asa, that conditionally 'requires' files in the
GlobalDir.

This fails miserably after upgrade to the latest version of Apache::ASP (we
were on 2.03 or something real old before).

I suspect that the culprit is the line:
   "no lib qw($self->{global});",

at the end of Apache::ASP::Parse:

    $$script = join(";;", 
                    $strict,
                    "use vars qw(\$".join(" \$",@Apache::ASP::Objects).')',
                    "use lib qw($self->{global});",
                    $$script,
                    "no lib qw($self->{global});",
                    );

Use lib adds the global directory to @INC at compile time, no lib removes it
again [at compile time].

All use's in the script will find files in the globaldir, as will requires
- as long as they are in a BEGIN block! Ifg they are outside a BEGIN block,
then the global dir is absent from @INC - even if it has cartefully been put
there beforehand.

Suggestion:
  remove the 'no lib' line

I can't see that it could have any negative effects - quite contariwise!
This will allow requires to require files in golbaldir as per the
docukmentation.. Otherwise a check should be added to see where globaldir is
in @INC beforehand, and not removing it if it is.

Regards
  Henrik Tougaard, FOA, Denmark.

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Re: Annoying use of "no lib" in Apache::ASP

Posted by Joshua Chamas <jo...@chamas.com>.
Henrik Tougaard wrote:
> 
> Use lib adds the global directory to @INC at compile time, no lib removes it
> again [at compile time].
> 
> All use's in the script will find files in the globaldir, as will requires
> - as long as they are in a BEGIN block! Ifg they are outside a BEGIN block,
> then the global dir is absent from @INC - even if it has cartefully been put
> there beforehand.
> 
> Suggestion:
>   remove the 'no lib' line
> 
> I can't see that it could have any negative effects - quite contariwise!
> This will allow requires to require files in golbaldir as per the

For web servers that have lots of Globals set, @INC can
get huge, growing by one for each Global configured.  For
virtual hosting scenarios, with each app getting its own
global, @INC will bloat by the number of virtual hosts.

This has been a problem before.

I can try a work around where the code does something like:

sub Apache::ASP::Execute {
  ...
  local @INC = ($Global, @INC);
  ...
}

This is nice because @INC will be magically restored
to how it was before after each script execute, so 
that lots of ASP applications with different Global's
set will not see each others Global directory.

This may also mean that manipulations of @INC during
an executing script will not be remembered later, but
this is probably a good thing anyway.

--Josh

_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks Founder                       Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org