in reply to Re: Deleting and replacing lines in a file
in thread Deleting and replacing lines in a file

To add to what robertes says, if you want to put the output of the program back over the input file (as you apparently do), you can use the -i flag of perl:
#!/usr/bin/perl -w -i.bak use strict; while (<>) # Loop over lines of file { next unless ($. > 2); # Ignore first two lines s/do my/replacement/ if ($. == 3); print $_; }
Then you can perl edit.pl myinput, which will move the input file to myinput.bak and put the output back in myinput