in reply to Deleting and replacing lines in a file

In addition to the fine advice given so far, I'd like to add some other WTDI:
#!/bin/perl -ni.bak print $. < 3 ? () : $. > 3 ? $_ : "new third\n";
#!/bin/perl -ni.bak print } BEGIN { scalar <>; scalar <>; scalar <>; print "This text replaces the third line.\n"; } {
Of course, it doesn't work right if you specify more than one file on the command line, but hey...

jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.