my @list_a = qw (3 1 2 5 4); my @list_b = qw (5 3 6 2 7 1 4); my @list_c = grep {my $x=$_; !grep {$x==$_} @list_a} @list_b; print "@list_c";