Komtanoo Pinpimai wrote: > Is there the "iterator variable" > for "for or foreach" loop ?
I just loaded a module to CPAN http://www.cpan.org/modules/by-authors/id/G/GS/GSLONDON called Iterate.pm with it, you can now do this: use Iterate; IterArray @array, sub { #do something to the array # the current array element is available in $_[0]; print "current value is ".($_[0])."\n"; # access the current index. # the iterator index is available in $_[1] print $another_array[$_[1]]; }; it can "map" as it iterates: my @mapped = IterArray @array, sub { if($_[0] =~ /pattern/) { return $_[0]; } else { return; } }; There are also iterators for hashes and file reads. hash iterators don't suffer iterator collisions if you nest an iterator on the same hash. Just uploaded it tonight, it might not be on CPAN just yet. Feedback welcome, Enjoy, Greg _______________________________________________ Boston-pm mailing list [EMAIL PROTECTED] http://mail.pm.org/mailman/listinfo/boston-pm

