in reply to Why doesn't the flip-flop operator work in all scalar contexts?
Let me ask the question: what do you want?
next, if 1 .. 3; will only call next when the left condition is true until the right condition is true.
Written differently:
while (<>) { next, if 2 .. 5; print; }
my $index = 0; my $skip = 0; while (<>) { $index++; if ($skip or $index == 2) { if ($index == 5) { $skip = 0; } next; } print; }
If your code is looping over a sequence of numbers or if you are using another counter then you might be able to use: next if $_ == 2 .. $_ == 5;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: When doesn't the flip-flop operator work in all scalar contexts?
by siracusa (Friar) on Oct 02, 2008 at 14:28 UTC | |
Re^2: When doesn't the flip-flop operator work in all scalar contexts?
by JadeNB (Chaplain) on Oct 02, 2008 at 18:00 UTC | |
by jethro (Monsignor) on Oct 02, 2008 at 18:56 UTC |