Subject: | Packed scripts don't work on perls < 5.8.0 |
Hi.
Just spotted this while trying to use cpanminus on perl 5.6.2 - it dies
complaining that it can't find one of the packed files
(App/cpanminus/script.pm).
The problem occurs in the @INC hook sub. In-memory files were only
introduced in 5.8.0 (according to the docs for open). If this line:
open my $fh, '<', \$fat;
is changed to:
open my $fh, '<', \$fat or die "can't open fatpacked $_[1]: $!";
it dies with:
Can't open fatpacked App/cpanminus/script.pm: No such file or
directory at cpanm line 5621.
Not sure what the best solution is. IO::String looks like the smallest
module that backports string filehandles (all the way back to 5.005_03).
Maybe pack that as well (possibly trimming out its write methods) in a
%fatpack_runtime or %fatpack_dependencies hash (in case any more are
needed)? It's not exactly a moving target (last updated in 2005).
Or perhaps add a --target or --min-version option to fatpack so that
it's only packed on request?
On a similar note, lexical filehandles were only introduced in 5.6
(according to perlfaq5), so ideally that "open my..." would need to be
tweaked as well for maximum backward-compatibility. Perhaps just trim
the fat from IO::String and use it in all cases? e.g.
return IO::String->new($fat)
or:
return FatPack::Handle->new($fat);
chocolateboy