use strict; use warnings; my $saw_an_s = 0; while (my $current_line = <DATA>) { next if ($saw_an_s and $current_line =~ /^s/); $saw_an_s = $current_line =~ /^s/ ? 1 : 0; print $current_line; } __DATA__ s 1 s 2 s 3 a a foo s 4 s 5 s 6 a bar
Just keep a flag rather than store the whole of the previous line each time - much simpler (to my mind). HTH.
In reply to Re: Issue with unless statement with two conditions acting on two lines
by hippo
in thread Issue with unless statement with two conditions acting on two lines
by rjc33
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |