in reply to Re^5: Easiest way to do something only on first iteration of loop
in thread Easiest way to do something only on first iteration of loop

One thing I didn't test was behavior in threads. I am not sure what would happen.

As with all variables that are not explicitly shared, each thread gets its own copy of any state variable; but within that thread it performs consistently with its behaviour in 'non-threaded' (single-threaded) code as you would expect:

CC:\test>perl -Mthreads -E" async{ for(1..4){ state $x = 123; say thre +ads->tid, ':', $x++ } }->join for 1 .. 4" 1:123 1:124 1:125 1:126 2:123 2:124 2:125 2:126 3:123 3:124 3:125 3:126 4:123 4:124 4:125 4:126

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.