Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Perl
Perl Misc
Idiom for array index that I'm foreach'ing over?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Eric J. Roode, post: 4750287"] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I think an OO interface is a good idea. If you do that, don't return the iteration value with the array values. Use a separate method for that. Perhaps something like this: $set = Array::Each->new (@x, @y); while (my ($x, $y) = $set->each()) { print "Iteration number ", $set->index(), "\n"; print " x = $x; y = $y\n"; print " last iteration!\n" if $set->exhausted(); } $set->rewind(); - -- Eric $_ = reverse sort $ /. r , qw p ekca lre uJ reh ts p , map $ _. $ " , qw e p h tona e and print -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13 iD8DBQE/19BsY96i4h5M0egRAmQeAKDXldiTn7DoAUwg99VLtKZDdEvfMgCgie64 TKeuP9sACsC0O/+Z2PhhAz8= =z5kt -----END PGP SIGNATURE----- [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Perl
Perl Misc
Idiom for array index that I'm foreach'ing over?
Top