Finding what's been added to @INC
Abigail
abigail at abigail.be
Tue Jul 15 21:00:46 BST 2008
On Tue, Jul 15, 2008 at 08:34:06PM +0100, Simon Wistow wrote:
> I'd like to be able to walk @INC trying to find everything that's been
> added above and beyond what you'd see from perl -V.
>
> I can't seem to find anything in %Config that's got the information in
> so I'm wondering if I can do something clever with a coderef in %INC or
> something. My current best guess is
>
> my %libs = map { $_ => 1 } @INC;
> delete $libs{$_} for @lib::ORIG_INC;
> print join("\n", keys %libs)."\n";
>
> but that doesn't count stuff that was passed in on the command line -
> i.e it will print 'lib' if I have a
>
> use lib qw(lib);
>
> but not if I do
>
> perl -Ilib
>
> unfortunately I can't seem to find anything in perlvar that will tell me
> what command line options Perl was invoked with. Then I also have to
> deal with things like -Mblib
>
> Anybody got any ideas?
Just run perl -V and subtract that from @INC?
$ perl -Ifoo -E 'use lib "bar";
@inc{@INC}=(); $_=`perl -V`; s/.*\@INC:\s*//s;
delete $inc{$_} for /(\S+)/g; say for keys %inc'
bar
foo
$
Abigail
More information about the london.pm
mailing list