Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: map-like hash iterator

by particle (Vicar)
on Nov 06, 2002 at 23:32 UTC ( [id://210960]=note: print w/replies, xml ) Need Help??


in reply to map-like hash iterator

see mugwumpjism's prior art in his response to the mapcar -- map for more than one list node.

code here for those too lazy to click above...

sub mapeach (&\%) { my $sub = shift; my $hash = shift or do { require Carp; Carp::croak( "mapeach: Nothing to map" ); }; my @ret; while ( my ($k, $v) = each %{$hash}) { local ($_) = $k; push @ret, $sub->($k, $v); } return wantarray ? @ret : { @ret }; }

~Particle *accelerates*

Replies are listed 'Best First'.
Re: Re: map-like hash iterator
by jdporter (Paladin) on Nov 07, 2002 at 00:00 UTC

    Prior art? He posted that on 2001-11-30. My post to FWP was on 2001-03-29.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://210960]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-23 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found