http://qs321.pair.com?node_id=1099718


in reply to Comparing 2 hash tables where values are stored in arrays

I'd use List::Compare (though I'm not sure I like its object-oriented interface):

#!/usr/bin/perl use strict; use warnings; use feature qw/say/; use List::Compare; use List::MoreUtils qw/uniq/; my %hash1 = ("abc" => [1, 2, 3, 4]); my %hash2 = ("abc" => [1, 3, 5, 7]); $, = ","; foreach my $key (uniq (keys %hash1, keys %hash2)) { my $lc = List::Compare->new($hash1{$key} // [], $hash2{$key} // [] +); say $lc->get_Lonly; # elements only in $hash1{$key} say $lc->get_Ronly; # elements only in $hash2{$key} }