in reply to Re: Easiest way to do something only on first iteration of loop
in thread Easiest way to do something only on first iteration of loop
I've tried a shorter version of #1, setting my $next_time = 1 and then testing for (!--$next_time) but that's sort of ridiculous.
In your second alternative, with the 'state' variable, does the state variable ever become zero again? The perldoc seems to say it is never reinitialized.
I didn't know about using 'each' with an array, as in your third alternative. That's neat.
Obviously there's not a brilliantly compact idiom :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Easiest way to do something only on first iteration of loop
by Marshall (Canon) on May 07, 2016 at 03:07 UTC | |
by Athanasius (Archbishop) on May 08, 2016 at 06:53 UTC | |
by Marshall (Canon) on May 08, 2016 at 12:21 UTC | |
by BrowserUk (Patriarch) on May 08, 2016 at 12:48 UTC |