in reply to Line Renumbering

Something like this?
#!/usr/bin/perl -w use strict; open(OLDF,"file.txt") || die $!; open(NEWF,">newfile.txt") || die $!; my $line=1; while (<OLDF>) { s/^\s*(N\d+)?\s*/N$line /; print NEWF; $line++; } close(OLDF); close(NEWF);

cLive ;-)

--
seek(JOB,$$LA,0);

Replies are listed 'Best First'.
Re: Re: Line Renumbering
by spiderman (Monk) on Aug 29, 2002 at 19:10 UTC
    How about something simple like: #!perl $myfile="c:/myfile.txt"; open MYFILE, $myfile or die "Cannot open $myfile for read :$!"; while (<MYFILE>) { print "N1 $. $_"; } while (<MYFILE>) { print "N $. $_"; }
      OOPS My Bad- the above post shoulda been: #!perl $myfile="c:/myfile.txt"; open MYFILE, $myfile or die "Cannot open $myfile for read :$!"; while (<MYFILE>) { print "N1 $. $_"; }