- if (open(IN,$file)) {
- my @lines = <IN>;
- close IN;
-
- my $total = scalar @lines;
- my $spread = 0;
- my $done = 0;
- for(my $i=0; $i<=$total; $i++) {
- next unless (exists $done{$file}{$i+$contextspread} or $spread);
-
- if (exists $done{$file}{$i+$contextspread}) {
- print "@@ $i @@\n" unless ($spread);
- # max lines between offending lines should be 2*context-1.
- # coincidence that it is!
- $spread = 2*$contextspread;
- } else {
- $spread--;
- }
-
- if (exists $done{$file}{$i}) {
- print "*** ";
- } else {
- print "--- ";
- }
-
- if ($i >= $total) {
- print "EOF\n";
- } else {
- print $lines[$i];
- }
- }
- print "\n";
- } else {
- print "=> error: could not open file.\n";
+ if ( open( IN, $file ) ) {
+ my @lines = <IN>;
+ close IN;
+
+ my $total = scalar @lines;
+ my $spread = 0;
+ my $done = 0;
+ for ( my $i = 0 ; $i <= $total ; $i++ ) {
+ next
+ unless ( exists $done{$file}{ $i + $contextspread } or $spread );
+
+ if ( exists $done{$file}{ $i + $contextspread } ) {
+ print "@@ $i @@\n" unless ($spread);
+
+ # max lines between offending lines should be 2*context-1.
+ # coincidence that it is!
+ $spread = 2 * $contextspread;
+ }
+ else {
+ $spread--;
+ }
+
+ if ( exists $done{$file}{$i} ) {
+ print "*** ";
+ }
+ else {
+ print "--- ";
+ }
+
+ if ( $i >= $total ) {
+ print "EOF\n";
+ }
+ else {
+ print $lines[$i];
+ }
+ }
+ print "\n";
+ }
+ else {
+ print "=> error: could not open file.\n";