in reply to Construct for Skipping and Continue
The scalar range operator, or flip-flop, is handy for constructs like this:
That makes the decision to print be carried by the state of the range operator. A simpler loop results.my @arr = qw( bar qux foo qux2 bar2 foo foo3 ); my $marker = "foo"; for (@arr) { print $_, $/ if ($marker eq $_) .. 1; } __END__ foo qux2 bar2 foo foo3
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Construct for Skipping and Continue
by GrandFather (Saint) on Feb 23, 2007 at 03:34 UTC |