in reply to Howto Compare 2 lists
You can use grep to find the members of list_a that are not members of list_b all in the same line of code.
The use of multiple greps is expensive where @list_a is larger than a few elements. A hash lookup would be preferred.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";
|
|---|