#! perl -slw use strict; use Data::Dumper; my $table=[[1,2,2,3,2,1],[qw(a b c d e a)],[qw(A D D C B A)]]; #! Convert your AoA's to a HoA's. #! Use the values from the arrays as the key and store the indices in the array #! You could just store the index as the value if the keys are unique. #! Better to build it this way in the first place though. my %table; push @{$table{"0:$table->[0][$_] 1:$table->[1][$_] 2:$table->[2][$_]"}}, $_ for 0..$#{$table->[0]}; print Dumper(\%table); #! To find all entries which match on all three elements my @elements = qw(0:1 1:a 2:A); my @matches = @{$table{"@elements"}} if exists $table{"@elements"}; print "Element ids: @matches contained elements: @elements"; #! To find elements that match on a subset @matches = (); /0:2/ and /2:D/ and push @matches, @{$table{$_}} for keys %table; print "Element ids @matches contain elements: 0:2 2:D";