in reply to Re^2: delete above matching line?
in thread delete above matching line?
my @out; my $print = 1; while (<>) { if (m/^start_of_block/) { $print = 0; pop @out if @out and $out[-1] eq $/; # removes previous empty line } push @out, $_ if $print; if (m/^};/) { $print = 1; } print shift @out if $print and 1 < @out; } # UPDATE: based on oldmanwillow reply: # print @out; print @out if $out[-1] =~ /^\s*$/ ;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: delete above matching line?
by oldmanwillow (Novice) on Jul 01, 2010 at 16:34 UTC |