use strict; use warnings; use Data::Dumper; my $temp = [ [ '/', '/index.html', '/products/' ], [ '/', '/index.html', ], [ '/', '/index.html', '/products/' ], [ '/', '/index.html', '/test.html', ] ]; # Count for the smallest array my $size = @{$temp->[0]}; my $numterms = @{$temp}; # Build the initial list my $seen = {}; map{ $seen->{$_}++} @{$temp->[0]}; my $success = 1; for(my $i = 1; $i < @{$temp}; $i++) { map { $seen->{$_}++ if exists($seen->{$_});}(@{$temp->[$i]}); } my @results; while(my ($key,$value) = each(%{$seen})) { if($value == $numterms) { push @results,$key; } } print STDERR Data::Dumper->Dump([\@results]);