Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

(jeffa) Re: one-liner to merge arrays

by jeffa (Bishop)
on Sep 27, 2001 at 23:25 UTC ( [id://115218]=note: print w/replies, xml ) Need Help??


in reply to one-liner to merge arrays (Re: A C-like brain in a Perl-like world)
in thread A C-like brain in a Perl-like world

The reason why is because your map is evaluating into a hash reference, not a hash - values take a hash for it's argument, not a hash reference. Now, if you use a tempory hash reference instead, the reason for the double curlies becomes much more apparent:
my $hash = { map {$_ => $_ } @a,@b }; my @merged = values %{ $hash };
Good question, by the way :)

jeffa

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-23 08:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found