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

Re: Probably an easy map question

by shmem (Chancellor)
on Jan 15, 2009 at 02:01 UTC ( [id://736435]=note: print w/replies, xml ) Need Help??


in reply to Probably an easy map question

Your usage of map is fine - but it isn't for chomp.

%hash = map { chomp; my ( $a, $b) = split / = /; $a => $b } <INF>;

should do. update: note that $_ is implicit for chomp and split.

Replies are listed 'Best First'.
Re^2: Probably an easy map question
by andye (Curate) on Jan 15, 2009 at 17:02 UTC
    I don't think you need $a and $b, split should do the job by itself:

    my %hash = map {chomp; split / = /} <INT>;
    all the best, andye

      I shouldn't use ($a, $b) since these are special and for something else - but I adhered to the OP's code in order to not change too much... ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-03-29 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found