X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FApp%2FFatPacker%2FTrace.pm;h=1da59431cc2e9555d341271e701a18ba750f318b;hb=dc7a3a086bb4da8332ab8c8b07716698e565c7a7;hp=6d1f68a882ebf59cbb4be89708617a4f07158227;hpb=2de6023fa2446e62f0c0e1cf29f6b6086a751cf2;p=p5sagit%2FApp-FatPacker.git diff --git a/lib/App/FatPacker/Trace.pm b/lib/App/FatPacker/Trace.pm index 6d1f68a..1da5943 100644 --- a/lib/App/FatPacker/Trace.pm +++ b/lib/App/FatPacker/Trace.pm @@ -4,14 +4,28 @@ use strict; use warnings FATAL => 'all'; use B (); +my $trace_file; +my %initial_inc; + sub import { - my $open = $_[1] || '>>fatpacker.trace'; - open my $trace, $open - or die "Couldn't open ${open} to trace to: $!"; - unshift @INC, sub { - print $trace "$_[1]\n"; - }; + $trace_file = $_[1] || '>>fatpacker.trace'; + # For filtering out our own deps later. + # (Not strictly required as these are core only and won't have packlists, but + # looks neater.) + %initial_inc = %INC; B::minus_c; } +CHECK { + return unless $trace_file; # not imported + + open my $trace, $trace_file + or die "Couldn't open $trace_file to trace to: $!"; + + for my $inc(keys %INC) { + next if exists $initial_inc{$inc}; + print $trace "$inc\n"; + } +} + 1;