Debian Codegraph @

pod/tidypod

raw
1 #!/usr/local/bin/new/perl -w
2
3 undef $/;
4 $^I = '.bak';
5
6 my @undo;
7
8 my $edits = 0;
9 while (<>)
10 {
11 $edits += s/[\t ]+(?=\n)//mg;
12 $edits += s/\n=back\n+=over\s+\d+\n/\n\n/mg;
13 $edits += s/\n{3,}/\n\n/mg;
14 $edits += s/L<(\w+)\.pod>/L<Tk::$1>/mg;
15 $edits += s/I<(\$\w+)-E<gt>>/I<$1>-E<gt>/mg;
16 $edits += s/^See the L<Tk::options> documentation for details[^\.]*\.\n/See L<Tk::options> for details of the standard options.\n/mg;
17
18 # I<$this>-E<gt>B<... --> I<$this>->B<...
19 # B<-\w+> =E<gt> --> B<-$1> =>
20 # $edits += s/I<\$(\w+)>-E<gt>/I<\$$1>->/mg;
21 # $edits += s/([IB]<-?\w+>\s*)=E<gt>/$1=>/mg;
22
23 print;
24 if (eof)
25 {
26 warn "$edits $ARGV\n";
27 push(@undo,$ARGV) unless $edits;
28 $edits = 0;
29 }
30 }
31
32 foreach my $file (@undo)
33 {
34 if (-f "$file$^I")
35 {
36 unlink($file) if -f $file;
37 rename("$file$^I",$file);
38 }
39 }