Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Parsing attributes in one line using map

by jhourcle (Prior)
on Sep 25, 2006 at 13:38 UTC ( [id://574732]=note: print w/replies, xml ) Need Help??


in reply to Re: Parsing attributes in one line using map
in thread Parsing attributes in one line using map

Returning more (or less even) elements than provided is very natural for map and very commonly used, especially for generating hashes ..

For those not familiar with returning less -- use an empty list (). To build on davidrw's example:

perl -MData::Dumper -le 'my %oddcubes = map { $_%2 ? ($_ => $_**3) : ( +) } 1..9; print Dumper \%oddcubes' $VAR1 = { '1' => 1, '3' => 27, '7' => 343, '9' => 729, '5' => 125 };

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 13:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found