monkfan has asked for the wisdom of the Perl Monks concerning the following question:
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Construct for Skipping and Continue
by GrandFather (Saint) on Feb 23, 2007 at 02:53 UTC | |
|
Re: Construct for Skipping and Continue
by imp (Priest) on Feb 23, 2007 at 02:32 UTC | |
|
Re: Construct for Skipping and Continue
by Zaxo (Archbishop) on Feb 23, 2007 at 03:00 UTC | |
by GrandFather (Saint) on Feb 23, 2007 at 03:34 UTC | |
|
Re: Construct for Skipping and Continue
by rhesa (Vicar) on Feb 23, 2007 at 02:52 UTC |