findCommon ([1, 2, 2], [2, 2, 3]); #### sub findCommon { my @lists = @_; my @common; while (@lists == grep {@$_} @lists) { my %hits; $hits{$_->[0]}++ for @lists; my $least = (sort keys %hits)[0]; push @common, $least if $hits{$least} == @lists; $_->[0] eq $least && shift @$_ for @lists; } return @common; }