#!/usr/local/bin/new/perl -w undef $/; $^I = '.bak'; my @undo; my $edits = 0; while (<>) { $edits += s/[\t ]+(?=\n)//mg; $edits += s/\n=back\n+=over\s+\d+\n/\n\n/mg; $edits += s/\n{3,}/\n\n/mg; $edits += s/L<(\w+)\.pod>/L/mg; $edits += s/I<(\$\w+)-E>/I<$1>-E/mg; $edits += s/^See the L documentation for details[^\.]*\.\n/See L for details of the standard options.\n/mg; # I<$this>-EB<... --> I<$this>->B<... # B<-\w+> =E --> B<-$1> => # $edits += s/I<\$(\w+)>-E/I<\$$1>->/mg; # $edits += s/([IB]<-?\w+>\s*)=E/$1=>/mg; print; if (eof) { warn "$edits $ARGV\n"; push(@undo,$ARGV) unless $edits; $edits = 0; } } foreach my $file (@undo) { if (-f "$file$^I") { unlink($file) if -f $file; rename("$file$^I",$file); } }