in reply to Re^3: delete above matching line?
in thread delete above matching line?
This almost works, and I like it much better than reading the whole file into a string. Thanks!
The only problem is that as it is, the script leaves a trailing newline if the deleted block is the last in the file. Probably my fault for not specifying that the blocks run to the end of the file.
The fix is simply to change the last
print @out ;to
print @out if $out[-1] =~ /^\s*$/ ;
|
|---|