[rt.cpan.org #60622] Handle conditional loading
[p5sagit/App-FatPacker.git] / lib / App / FatPacker / Trace.pm
CommitLineData
48af1939 1package App::FatPacker::Trace;
2
3use strict;
4use warnings FATAL => 'all';
5use B ();
6
dc7a3a08 7my $trace_file;
8my %initial_inc;
9
48af1939 10sub import {
dc7a3a08 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;
48af1939 16 B::minus_c;
17}
18
dc7a3a08 19CHECK {
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
48af1939 311;