in reply to How to delete and add line in the middle of a file?
You can read more about in-place editing in perlvar($^I) and perlrun(-i).local ($^I,@ARGV)=('.bak','file.html'); my $p=1; while(<>){ $p-- if /<\/tr>/; print "Add this line\n" if $p==-4 print if $p; $p-- if /<tr>/; }
|
|---|