3 # leading and trailing context lines.
11 print "Usage: parse_warn.pl <files>\n";
12 print "Example: parse_warn.pl log/*\n";
19 foreach $file (@ARGV) {
21 print "warning: $file does not exist.\n";
24 my $str = ' at .* line ';
26 print "Opening $file... ";
27 if ($file =~ /bz2$/) { # bz2
28 open(FILE, "bzcat $file | egrep '$str' |");
29 } elsif ($file =~ /gz$/) { # gz
30 open(FILE, "zegrep '$str' $file |");
32 open(FILE, "egrep '$str' $file |");
37 if (/ at (\S+) line (\d+)/) {
38 my ($file,$lineno) = ($1,$2+1);
39 $done{$file}{$lineno}++;
47 foreach $file (keys %done) {
48 my $count = scalar(keys %{$done{$file}});
49 print "warn $file: $count unique warnings.\n";
52 print "=> error: does not exist.\n\n";
60 my $total = scalar @lines;
63 for(my $i=0; $i<=$total; $i++) {
64 next unless (exists $done{$file}{$i+$contextspread} or $spread);
66 if (exists $done{$file}{$i+$contextspread}) {
67 print "@@ $i @@\n" unless ($spread);
68 # max lines between offending lines should be 2*context-1.
69 # coincidence that it is!
70 $spread = 2*$contextspread;
75 if (exists $done{$file}{$i}) {
89 print "=> error: could not open file.\n";