1da59431cc2e9555d341271e701a18ba750f318b
[p5sagit/App-FatPacker.git] / lib / App / FatPacker / Trace.pm
1 package App::FatPacker::Trace;
2
3 use strict;
4 use warnings FATAL => 'all';
5 use B ();
6
7 my $trace_file;
8 my %initial_inc;
9
10 sub import {
11   $trace_file = $_[1] || '>>fatpacker.trace';
12   # For filtering out our own deps later.
13   # (Not strictly required as these are core only and won't have packlists, but 
14   # looks neater.)
15   %initial_inc = %INC;
16   B::minus_c;
17 }
18
19 CHECK {
20   return unless $trace_file; # not imported
21
22   open my $trace, $trace_file
23       or die "Couldn't open $trace_file to trace to: $!";
24
25   for my $inc(keys %INC) {
26     next if exists $initial_inc{$inc};
27     print $trace "$inc\n";
28   }
29 }
30
31 1;