in reply to Re^2: comparing arrays
in thread comparing arrays
it doesn't matter which array the values are removed from.
In that case, it is very simple. You iterate over one array and rebuild it. If a value shows up in the second array, you just ignore it as you are rebuilding. Use a hash to store the values so that lookup is fast...
my @array1 = (1, 2, 3, 4, 5); my @array2 = (2, 4, 6, 8, 10); my %hash = map {$_=>1} @array2; @array1 = grep { not exists $hash{$_} } @array1; print "@array1\n";
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: comparing arrays
by Animator (Hermit) on Dec 16, 2004 at 15:16 UTC |