#! perl -slw use strict; sub hmap(&%) { use vars qw[ $h $v ]; my $code = shift; my @rv; local( $h, $v ) = splice( @_, 0, 2 ), push @rv, $code->() while @_; return @rv } sub hgrep (&%) { use vars qw[ $h $v ]; my $code = shift; my @rv; local( $h, $v ) = splice( @_, 0, 2 ), push @rv, $code->() ? ( $h, $v ) : () while @_; return @rv; } my %h = 'a' .. 'z'; print %h; my %r = hmap{ $h => ++$v } %h; print %r; my %s = hgrep{ $h le 'm' } %r; print %s; __END__ [19:25:50.05] C:\test>hmap wxefabmnstyzuvcdklqrghijop egwyacmosuyaauwcekmgiqsoqik egcekmacgimoik