http://www.perlmonks.org?node_id=601670

monkfan has asked for the wisdom of the Perl Monks concerning the following question:

Dear experts,
Suppose I have the following array and marker:
my @arr = qw( bar qux foo qux2 bar2 foo foo3 ); my $marker = "foo";
What I intend to do is to print all the elements of the array starting from marker first found to the end of the array. Yielding:
foo qux2 bar2 foo foo3
Thus skippping the first two elements of the array ("bar" and "qux"). What's the best construct to achieve that? I've tried the following, but it doesn't give the result I desired:
my @arr = qw( bar qux foo qux2 bar2 foo foo3 ); my $marker = "foo"; foreach my $arr (@arr) { next unless ($arr eq $marker); print "$arr\n"; } continue { print "$arr\n"; }

Regards,
Edward