use strict; use warnings; my $saw_an_s = 0; while (my $current_line = ) { 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