develooper Front page | perl.perl5.porters | Postings from February 2013

Keeping track of used modules (Was: Perl 7 or Perl 2013?)

Thread Previous | Thread Next
From:
Jan Dubois
Date:
February 12, 2013 19:35
Subject:
Keeping track of used modules (Was: Perl 7 or Perl 2013?)
Message ID:
CAD-TLz-r6Avh5pyN=aQU63XvB44ora_FX9Btv9NgLNQE8T9D3g@mail.gmail.com
Forgot to CC p5p


---------- Forwarded message ----------
From: Jan Dubois <jand@activestate.com>
Date: Tue, Feb 12, 2013 at 11:16 AM
Subject: Re: Keeping track of used modules (Was: Perl 7 or Perl 2013?)
To: demerphq <demerphq@gmail.com>


On Tue, Feb 12, 2013 at 11:02 AM, demerphq <demerphq@gmail.com> wrote:
> On 12 February 2013 12:16, David Golden <xdg@xdg.me> wrote:
>> I leave it to the reader to convert that back to a list of modules.
>
> What, the solution doesn't fit into this margin? ;-)

Put this into your sitecustomize.pl file:

END { require DB_File; tie my %h, "DB_File", "$ENV{HOME}/zzz";
$h{$_}++ for values %INC }

Demo:

$ perl -Mstrict -E 'END { require DB_File; tie my %h, "DB_File",
"$ENV{HOME}/zzz"; $h{$_}++ for values %INC} say 42'
42
$ perl -MDB_File -E 'tie %h, "DB_File", "$ENV{HOME}/zzz"; printf "%s:
%d\n", $_, $h{$_} for sort keys %h'
/usr/local/ActivePerl-5.16/lib/AutoLoader.pm: 1
/usr/local/ActivePerl-5.16/lib/Carp.pm: 1
/usr/local/ActivePerl-5.16/lib/DB_File.pm: 1
/usr/local/ActivePerl-5.16/lib/Exporter.pm: 1
/usr/local/ActivePerl-5.16/lib/Fcntl.pm: 1
/usr/local/ActivePerl-5.16/lib/File/Spec.pm: 1
/usr/local/ActivePerl-5.16/lib/File/Spec/Unix.pm: 1
/usr/local/ActivePerl-5.16/lib/Tie/Hash.pm: 1
/usr/local/ActivePerl-5.16/lib/XSLoader.pm: 1
/usr/local/ActivePerl-5.16/lib/auto/DB_File/autosplit.ix: 1
/usr/local/ActivePerl-5.16/lib/feature.pm: 1
/usr/local/ActivePerl-5.16/lib/strict.pm: 1
/usr/local/ActivePerl-5.16/lib/vars.pm: 1
/usr/local/ActivePerl-5.16/lib/warnings.pm: 1
/usr/local/ActivePerl-5.16/lib/warnings/register.pm: 1
/usr/local/ActivePerl-5.16/site/lib/sitecustomize.pl: 1

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