From: Diab Jerius Date: Sun, 17 Nov 2013 02:25:17 +0000 (-0500) Subject: push object as @INC hook for all perls X-Git-Tag: v0.010000~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=330208685b5d89310db66f485c954f31edf7d0ac;p=p5sagit%2FApp-FatPacker.git push object as @INC hook for all perls the object's INC method returns a sub for perl < 5.008 otherwise a filehandle --- diff --git a/lib/App/FatPacker.pm b/lib/App/FatPacker.pm index 24abeaf..e742f6a 100644 --- a/lib/App/FatPacker.pm +++ b/lib/App/FatPacker.pm @@ -268,9 +268,12 @@ sub fatpack_end { return stripspace <<' END_END'; s/^ //mg for values %fatpacked; + my $class = "${\\%fatpacked}"; + *{"${class}::files"} = sub { keys %{$_[0]} }; if ($] < 5.008) { - unshift @INC, sub { + + *{"${class}::INC"} = sub { if (my $fat = $fatpacked{$_[1]}) { return sub { return 0 unless length $fat; @@ -285,9 +288,6 @@ sub fatpack_end { else { - my $class = "${\\%fatpacked}"; - unshift @INC, bless \%fatpacked, $class; - *{"${class}::files"} = sub { keys %{$_[0]} }; *{"${class}::INC"} = sub { if (my $fat = $_[0]{$_[1]}) { open my $fh, '<', \$fat @@ -299,6 +299,7 @@ sub fatpack_end { } + unshift @INC, bless \%fatpacked, $class; } # END OF FATPACK CODE END_END }