Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: Array to hash refs

by aufrank (Pilgrim)
on Aug 13, 2002 at 16:25 UTC ( #189856=note: print w/replies, xml ) Need Help??


in reply to Re: Array to hash refs
in thread Array to hash refs

my @array = qw /a b c/; my %hash = map {$_ => 1} @array; return \%hash;

can that be done with a map and a hashref rather than having to return a hashref? ripped off from tadman in Re: an easier way with grep, map, and/or sort?.
--au

Replies are listed 'Best First'.
Re: Array to hash refs
by Abigail-II (Bishop) on Aug 13, 2002 at 16:28 UTC
    return {map {$_ => 1} qw /a b c/}
    Or did I understand your questing wrong?

    Abigail

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2022-12-09 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?