@@ -67,6 +67,7 @@ sub main {
67
67
my $packer = MyPacker-> new;
68
68
my $packed ;
69
69
70
+ # ------------------------------------------
70
71
say STDERR " Packing..." ;
71
72
do {
72
73
open my $savedstdout , ' >&' , STDOUT or die $! ; # save stdout
@@ -80,46 +81,46 @@ sub main {
80
81
};
81
82
say STDERR " ...done" ;
82
83
83
- # Clean up, and move the Text::PerlPP pod where pod2usage can find it
84
+ # ------------------------------------------
85
+ # Clean up the fatpacked output
84
86
85
87
my @lines ; # For the source
86
- my @podlines ; # For the POD we're going to move
87
88
88
- my ( $in_getopt , $in_text , $ in_doc) ;
89
+ my $ in_doc ;
89
90
90
91
say STDERR " Cleanup..." ;
91
92
open my $iter , ' <' , \$packed ;
92
93
94
+ # Force the shebang for convenience in distributing the packed version
95
+ if (defined (my $line = <$iter >)) {
96
+ chomp $line ;
97
+ $line =~ s { ^#!.*$} { #!/usr/bin/env perl} ;
98
+ push @lines , $line ;
99
+ }
100
+
101
+ # Strip fatpacked POD to save space.
93
102
while (<$iter >) {
94
103
chomp ;
95
104
s /\s +$// ;
96
105
97
- $in_getopt = m { fatpacked\S +Getopt/Long} .. m { ^GETOPT_LONG} ;
98
- $in_text = m { fatpacked\S +Text/PerlPP} .. m { ^TEXT_PERLPP} ;
99
- $in_doc = /^ =head1 NAME/ .. /^ =cut/;
106
+ $in_doc = /^ (=pod|=head1 NAME)/ .. /^ =cut/;
100
107
# have to test indentation level because the POD for Getopt::Long
101
- # includes a quoted POD sample
108
+ # includes a quoted POD sample, which we don't want to detect,
109
+ # and because the bin/perlpp POD we want to keep is not indented.
102
110
103
- # print STDERR "$in_getopt\t$in_text\t$in_doc\t$_\n";
104
-
105
- next if $in_getopt && $in_doc ; # no POD for Getopt::Long
106
- if ($in_text && $in_doc && ($in_text !~ / E0$ / )) {
107
- s / ^ // ;
108
- push @podlines , $_ ;
109
- } else {
110
- push @lines , $_ if $_ ;
111
- }
111
+ push @lines , $_ unless $in_doc ; # no embedded POD
112
112
}
113
113
close $iter ;
114
114
undef $packed ;
115
115
say STDERR " ...done" ;
116
116
117
- # Output in the appropriate order
117
+ # ------------------------------------------
118
+ # Output in the appropriate order. This is a separate pass from the
119
+ # cleanup for historical reasons.
120
+
118
121
say STDERR " Generating blib/perlpp..." ;
119
122
open my $fh , ' >' , ' blib/perlpp' ;
120
- print $fh " $_ \n " for @lines ;
121
- print $fh " __END__\n =pod\n\n " ;
122
- print $fh " $_ \n " for @podlines ;
123
+ say $fh $_ for @lines ;
123
124
close $fh ;
124
125
125
126
print STDERR " Done packing\n " ;
0 commit comments