Unfortunately, when using
<> (as -p does),
$. is not reset after the close of each file.
However, there is an example in the
perlfunc:eof documentation of how to get around this (basically, you just have to do an explicit test of
eof, then close the filehandle when it is found). The example is easily modified to fit this problem:
#!/usr/bin/perl -i.bak
while (<>) {
s/^(N\d+ )?/N$. /;
}
continue {
print;
close ARGV if eof;
}
-- Mike
--
just,my${.02}