Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Probably an easy map question

by shmem (Chancellor)
on Jan 15, 2009 at 02:01 UTC ( #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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://736435]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2018-07-18 16:55 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (393 votes). Check out past polls.