summaryrefslogtreecommitdiff
path: root/lib/AutoSplit.pm
diff options
context:
space:
mode:
authorChip Salzenberg <chip@atlantic.net>1997-01-16 07:24:00 +1200
committerChip Salzenberg <chip@atlantic.net>1997-01-16 07:24:00 +1200
commit96bc026d9c645175facfed3d043c4a1db3284a10 (patch)
tree21e5f24ac8320b144d5e8a08bc5a721d187ef0a5 /lib/AutoSplit.pm
parent7adad424447c8a24bce71f2593459be2ef4eb957 (diff)
downloadperl-96bc026d9c645175facfed3d043c4a1db3284a10.tar.gz
PATCH: AutoSplit
(this is the same change as commit bb8fceff88bc3fe9e820d0761f1b0451a870ac65, but as applied)
Diffstat (limited to 'lib/AutoSplit.pm')
-rw-r--r--lib/AutoSplit.pm23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/AutoSplit.pm b/lib/AutoSplit.pm
index cc9de33f26..c1ff13a70c 100644
--- a/lib/AutoSplit.pm
+++ b/lib/AutoSplit.pm
@@ -248,7 +248,10 @@ sub autosplit_file{
open(OUT,">/dev/null") || open(OUT,">nla0:"); # avoid 'not opened' warning
my(@subnames, %proto);
+ my @cache = ();
+ my $caching = 1;
while (<IN>) {
+ next if /^=\w/ .. /^=cut/;
if (/^package ([\w:]+)\s*;/) {
warn "package $1; in AutoSplit section ignored. Not currently supported.";
}
@@ -275,10 +278,26 @@ sub autosplit_file{
print OUT "# NOTE: Derived from $filename. ",
"Changes made here will be lost.\n";
print OUT "package $package;\n\n";
+ print OUT @cache;
+ @cache = ();
+ $caching = 0;
+ }
+ if($caching) {
+ push(@cache, $_) if @cache || /\S/;
+ }
+ else {
+ print OUT $_;
+ }
+ if(/^}/) {
+ if($caching) {
+ print OUT @cache;
+ @cache = ();
+ }
+ print OUT "\n";
+ $caching = 1;
}
- print OUT $_;
}
- print OUT "1;\n";
+ print OUT @cache,"1;\n";
close(OUT);
close(IN);