use strict; use warnings; my @arr = qw( bar qux foo qux2 bar2 foo foo3 ); my $marker = "foo"; my $found = undef; for my $entry (@arr) { if ($entry eq $marker) { $found = 1; } if (defined $found) { print $entry, "\n"; } }