in reply to Removing duplicate values for a hash of arrays

G'day perlvroom,

This does what you want:

#!/usr/bin/env perl use strict; use warnings; use Data::Dump; my %hash = ('a' => ['1', '2'], 'b' => ['2', '3'], 'c' => ['1', '2']); dd \%hash; my %seen; $seen{join $; => @{$hash{$_}}}++ and delete $hash{$_} for keys %hash; dd \%hash;

Output:

{ a => [1, 2], b => [2, 3], c => [1, 2] } { a => [1, 2], b => [2, 3] }

You can use whatever you want as the join separator. I've used $; as it's probably unlikely to occur in your arrayref data; obviously, you'll have a better idea of this than me. It used to be used in Perl4 to emulate multidimensional arrays but it's rarely seen in Perl5 code: I occasionally find it useful in this sort of situation. Read about it in perlvar (aka $SUBSCRIPT_SEPARATOR and $SUBSEP).

-- Ken