in reply to Interesting Use for "state" Variables
(Defined execution order left as exercise for the reader)use feature ":5.10"; my %hash = map { $_ => state $i++ } qw(red blue green yellow black whi +te purple brown orange gray); for (1..2) { while (($k,$v) = each %hash) { do_something_with($k, $v); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Interesting Use for "state" Variables
by JavaFan (Canon) on Mar 10, 2009 at 22:36 UTC |