No such thing as a small change | |
PerlMonks |
Re: Implementing a cyclic arrayby citromatik (Curate) |
on Jun 19, 2009 at 12:39 UTC ( [id://773018]=note: print w/replies, xml ) | Need Help?? |
Tie::Cycle is a simple module that implements cyclic arrays through a tied reference (to the array):
Prints:
The last line ($cycle && $cycle->($_) for (@names);) seems a bit odd, but $cycle->($_) doesn't trigger the FETCH sub in the tied scalar (anybody knows why?) and a first call to $cycle is needed. citromatik
In Section
Seekers of Perl Wisdom
|
|