monkfan has asked for the wisdom of the Perl Monks concerning the following question:
Dear experts,
Suppose I have the following array and marker:
Regards,
Edward
Suppose I have the following array and marker:
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:my @arr = qw( bar qux foo qux2 bar2 foo foo3 ); my $marker = "foo";
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:foo qux2 bar2 foo foo3
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
Back to
Seekers of Perl Wisdom