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

Re: Remove duplicates from Hash of Arrays

by Kenosis (Priest)
on Dec 09, 2013 at 20:42 UTC ( #1066332=note: print w/ replies, xml ) Need Help??


in reply to Remove duplicates from Hash of Arrays

Perhaps the following will be helpful:

use strict; use warnings; my %h; my $HoA = { 'music' => [ 9, 53, 3, 15 ], 'conferences' => [ 7, 56, 15, 53 ], }; @h{@$_} = undef for values %$HoA; my @ids = keys %h; print "@ids"; # 53 56 3 7 9 15

What is this @h{@$_} = undef notation? See Hash from two arrays.


Comment on Re: Remove duplicates from Hash of Arrays
Select or Download Code
Re^2: Remove duplicates from Hash of Arrays
by Anonymous Monk on Dec 09, 2013 at 22:00 UTC
    Thanks, I will use this. After some reading up it seems setting each key to undefined can save memory when dealing with large arrays, as I sometimes will be.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2014-09-16 21:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (50 votes), past polls