21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
27 =item B<--maxiter|m=i>
29 Number of iterations, defaults to 1.
33 Megalogfile. Defaults to some historical file.
45 use lib
"$FindBin::Bin/../lib";
51 use File
::Basename
qw(dirname);
52 use File
::Path
qw(mkpath);
57 use Hash
::Util
qw(lock_keys);
60 lock_keys
%Opt, map { /([^=|!]+)/ } @opt;
67 $Opt{megalog
} //= "/home/sand/megalog/megalog-2018-10-05T23:09:31.log";
71 my $maxloops = $Opt{maxiter
} //= 1;
73 while (++$i <= $maxloops) {
74 my $yaml = qx{$^X bin
/snapshotflattener
.pl
--sfr
$Opt{megalog
}} or last;
75 my $y = YAML
::Load
$yaml;
76 die "Human help required for yaml[\n$yaml\n]\n" if $y->{line
} == 0;
77 my $snap = "lib/Bundle/Snapshot_2011_10_21_$y->{bfile}.pm";
78 rename $snap, "$snap~" or die "Could not rename $snap: $!";
79 open my $fh, "$snap~" or die "Could not open $snap~: $!";
80 open my $fh2, ">", $snap or die "Could not open >$snap: $!";
81 warn "About to process $y->{name} on $snap\n";
84 if ($m eq $y->{name
}) {
85 warn "$y->{name} found\n";
86 for my $dep (@
{$y->{deps
}}) {
89 warn sprintf "%d lines injected near bline %s\n", scalar @
{$y->{deps
}}, $y->{line
};
93 close $fh2 or die "Could not close $snap: $!";
94 system q
<perl
-i
~ -nle
' use strict; our(%IN,%S); BEGIN { $IN{contents}=0; } if (/^=head1 CONTENTS/){ $IN{contents}=1; print; next; } if (/^=/){ $IN{contents}=0; } if ($IN{contents}){ /^([A-Za-z]\S*)/ and $S{$1}++ and next; } print; ' lib
/Bundle/Snapshot_2011_10_21_0?
.pm
>;
99 # cperl-indent-level: 4