#! /usr/bin/perl -w
use strict ;
$|++ ;
my $line = 0 ;
while ( <DATA> ) {
next if /^%/ ;
s/^(?:N\d+\s?)?(?{$line++})/N$line / ;
} continue {
print ;
}
exit ;
__DATA__
% This is the first line.
N1 Hello there
N3 I'm a line of text
% but I won't be counted.
N5 Here I am, number three!
I don't have a line number, but I should be four.
% End of text
Output:
% This is the first line.
N1 Hello there
N2 I'm a line of text
% but I won't be counted.
N3 Here I am, number three!
N4 I don't have a line number, but I should be four.
% End of text
_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
--Friedrich Nietzsche
|