my $flag = 0; while () { if ($flag) { $flag = 0; do_something($_); } if (/pattern/) { $flag = 1; next; } }