Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 romping around the Monastery: (16)
As of 2015-07-06 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (74 votes), past polls