my @array1 = qw/a b c d e f/; my @array2 = qw/ b c d /; # you see: result must be a, e and f my @in1notin2 = do { my %tmp = map {($_=>undef)} @array2; grep not exists $tmp{$_}, @array1 }; print "The elements @in1notin2 can be found in array 1, but not in array 2\n";