$found = 0; foreach $j (1..@a-1) { if ($a eq $a[$j] && $b eq $b[$j]) { $found = 1; last; } } unless ($found) {do something}