Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Using map to create a hash/bag from an array

by mrborisguy (Hermit)
on Dec 18, 2005 at 04:22 UTC ( #517556=note: print w/ replies, xml ) Need Help??


in reply to Re: Using map to create a hash/bag from an array
in thread Using map to create a hash/bag from an array

Why not use for in this example, since you're not really transforming @items into a new array (common use of map), but rather just performing an action for each value in @items (common use of for).

$bag->{$_}++ for @items; # instead of map {$bag->{$_}++} @items;

    -Bryan


Comment on Re^2: Using map to create a hash/bag from an array
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2014-11-22 00:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (118 votes), past polls