use strict; my (@listA, @listB); $listA[0] = [qw(1 foo bar)]; $listB[0] = [qw(1 bar baz)]; my %hash = map { $_ => 1 } @{$listA[0]}; my @c = grep {! exists $hash{$_}} @{$listB[0]}; print "$_\n" foreach (@c);