#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11152381 use warnings; my %sets = ( A => [1,2,3], B => [3, 4], C => [1, 3, 4] ); my %seen; my @items = sort grep $seen{$_}++ == 1, map @$_, values %sets; print "Items in more than one set: @items\n";