my $end = stripspace <<' END_END';
s/^ //mg for values %fatpacked;
- unshift @INC, sub {
- if (my $fat = $fatpacked{$_[1]}) {
- open my $fh, '<', \$fat
- or die "FatPacker error loading $_[1] (could be a perl installation issue?)";
- return $fh;
- }
- return
- };
-
+ unshift @INC, sub {
+ if (my $fat = $fatpacked{$_[1]}) {
+ open my $fh, '<', \$fat
+ or die "FatPacker error loading $_[1] (could be a perl installation issue?)";
+ return $fh;
+ }
+ return
+ };
} # END OF FATPACK CODE
END_END
my @segments = map {
sub generate_file_data_style {
my($files, $main) = @_;
+ {
+ open my $main_fh, '<', $main or die "Can't open '$main': $!";
+ $files->{"fatpacked-main"} = join "", <$main_fh>;
+ }
+
my $start = stripspace <<' END_START';
# This chunk of stuff was generated by App::FatPacker. Do not edit.
- my %fatpacked = (
+ {
+ my %fatpacked = (
END_START
my @segments = map {
my $fatpack_data;
my $start_idx = 0;
for my $segment (@segments) {
- $fatpack_data .= " ".perlstring($segment->[0])." => [$start_idx, $segment->[1]],\n";
+ $fatpack_data .= " ".perlstring($segment->[0])." => [$start_idx, $segment->[1]],\n";
$start_idx += $segment->[1];
}
my $end = stripspace <<' END_END';
- );
-
- my $data_pos = tell DATA;
- unshift @INC, sub {
- if(my $fat = $fatpacked{$_[1]}) {
- seek DATA, $data_pos + $fat->[0], 0;
- local $/ = \$fat->[1];
- open my $fh, '<', \scalar <DATA>;
- return $fh;
- }
- };
+ );
+ my $data_pos = tell DATA;
+ unshift @INC, sub {
+ if(my $fat = $fatpacked{$_[1]}) {
+ seek DATA, $data_pos + $fat->[0], 0;
+ local $/ = \$fat->[1];
+ open my $fh, '<', \scalar <DATA>;
+ return $fh;
+ }
+ };
+ }
# END OF FATPACK CODE
- END_END
- open my $main_fh, '<', $main or die "Can't open '$main': $!";
+ do 'fatpacked-main' or die $@;
+ END_END
print join "\n", $start, $fatpack_data, $end;
- print join "", <$main_fh>, "\n";
print join "\n", "__DATA__", join "", map ${$_->[2]}, @segments;
}