Perl-Sensitive Sunglasses | |
PerlMonks |
Re^2: Array iterator factoryby Roy Johnson (Monsignor) |
on Mar 16, 2005 at 19:30 UTC ( [id://440107]=note: print w/replies, xml ) | Need Help?? |
If I took a list, I'd have to make and store a copy of its contents. It would be expensive, and it would not see subsequent changes to the original array. I wanted a lightweight iterator tied to a user-modifiable array.
The user can create an anonymous array and slap an iterator on it, if he so desires: array_iterator(@{[1..10]}). That makes it obvious that this iterator can't give you the free lunch that for (1..10) does. Caution: Contents may have been coded under pressure.
In Section
Cool Uses for Perl
|
|