Finding what's been added to @INC

Simon Wistow simon at thegestalt.org
Tue Jul 15 21:03:30 BST 2008


On Tue, Jul 15, 2008 at 08:34:06PM +0100, me said:
> Anybody got any ideas?

So one solution, suggested by Jess was to exec another Perl and diff 
their @INCs. We came up with


my %tmp = map { $_ => 1 } split ':', do
{
    local %ENV && delete $ENV{PERL5LIB};
    `$^X -e 'print join(":", \@INC)'`;
};
my @LOCALINC = grep { !$tmp{$_} } @INC;
print join("\n", @LOCALINC)."\n";

Running that on its own

% perl inctest

% perl -Mlib=lib inctest
lib

% perl -Iinc inctest
inc

% perl -Mblib inctest
/home/simon/testing/blib/arch
/home/simon/testing/blib/lib

% PERL5LIB=~/perllib inctest
/home/simon/perllib/5.8.5/x86_64-linux-thread-multi
/home/simon/perllib/5.8.5
/home/simon/perllib/x86_64-linux-thread-multi
/home/simon/perllib/5.8.4
/home/simon/perllib/5.8.3
/home/simon/perllib/5.8.2
/home/simon/perllib/5.8.1
/home/simon/perllib/5.8.0
/home/simon/perllib

I keep thinking that there ought to be a better way though.


More information about the london.pm mailing list