http://qs321.pair.com?node_id=210867

In this posting to the Fun With Perl mailing list, I presented a technique for iterating over the elements of a hash, in much the same way that map iterates over the contents of an array.

Yes, you can use map directly, but that means collecting all the keys of the hash up front, and that could be undesirable if the hash is large, or tied.

sub hasheesh(&\%) { my( $c, $h ) = @_; local( $a, $b ); @_ = (); while ( ( $a, $b ) = each %$h ) { push @_, $c->(); } @_ } # you'd use it like this: hasheesh { print "$a => $b\n" } %h; # or: print hasheesh { "$a => $b\n" } %h;