This is a more computation-efficient way that takes advantage of the fact that hash lookups are essentially O(1):
my %listA; @listA{@a}=(); foreach my $item ( @b ) { next if exists $listA{$item}; push @c, $item; }
Of course CPAN is your friend for this sort of thing. But I wanted to show the hash technique because it replaces a single slow O(n^2) algorithm with two faster O(n) operations, which is an order of magnitude more computationally efficient (but more of a memory hog too).
Dave
In reply to Re: List Comparison
by davido
in thread List Comparison
by ketema
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |