in reply to Re: I want to write a method that can be used with 'while ($thing = getNextThing() )'
in thread I want to write a method that can be used with 'while ($thing = getNextThing() )'
For example, this one goes in circles
my $coco = do { my @colors = qw[ pink maroon green OliveDrab4 PaleVioletRed3 RosyB +rown2 PeachPuff4 WhiteSmoke azure3 chartreuse1 coral3 gold1 firebrick +4 linen salmon4 tomato2 ]; my $ix = 0; my $size = int(@colors) ; sub { my $mod = $ix % $size; my $cix = $mod; warn "$ix $cix $colors[ $cix ]\n"; $ix++; return $colors[ $cix ]; }; }; $coco->() for 1 .. 100;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: I want to write a method that can be used with 'while ($thing = getNextThing() )'
by Cody Fendant (Hermit) on Aug 20, 2016 at 11:50 UTC |