Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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.

Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2018-03-23 18:54 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (296 votes). Check out past polls.