develooper Front page | perl.perl5.porters | Postings from March 2012

RE: pop @INC (".")

Thread Previous | Thread Next
From:
Jan Dubois
Date:
March 8, 2012 23:24
Subject:
RE: pop @INC (".")
Message ID:
006101ccfdc5$a94381a0$fbca84e0$@activestate.com
On Thu, 08 Mar 2012, Todd Rinaldo wrote:
> As best I can tell at the moment, sitecustomize would not do what
> you're describing,

It is certainly possible to do this with sitecustomize.pl, but it means
it will not be in effect if sitecustomize.pl processing is suppressed:

$ head -1 /usr/local/ActivePerl-5.12/site/lib/sitecustomize.pl 
@INC = grep $_ ne '.', @INC;
$ perl -f -V | tail -5
  Compiled at Feb  9 2011 14:47:05
  @INC:
    /usr/local/ActivePerl-5.12/site/lib
    /usr/local/ActivePerl-5.12/lib
    .
$ perl -V | tail -5
  Compiled at Feb  9 2011 14:47:05
  @INC:
    /Users/jan/Library/ActivePerl-5.12/lib
    /usr/local/ActivePerl-5.12/site/lib
    /usr/local/ActivePerl-5.12/lib
$

Note that this will always filter out '.' from anywhere in @INC,
so it would effectively disable -I.

If you don't want that, you could use

pop @INC if $INC[-1] eq '.';

You could even try to use some heuristics, like checking that $ARGV[0]
isn't Makefile.PL and doesn't start with t/ or xt/, and only remove
'.' when those conditions are false.  I would hate having such heuristics
inflicted on me though, so I won't recommend that you do this to others. :)

Cheers,
-Jan



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About