in reply to subtract one array from another

Probably one of the fastest and most reliable ways would be to do the following:

# create a hash representing @array2 my %hash; $hash{$_} = undef foreach (@array2); # grep only leaves what evaluates to true. # if an element of array1 is not in array2, it is # left in place @array1 = grep { not exists $hash{$_} } @array1;

To perform your original approach, you would probably want to use the command splice, like so:

if($array1[$search] eq $array[$search2]){ splice(@array1,$search,1); # remove 1 element from index $search i +n @array1 $search--; # the next element is already at $search. decrement so +when it's incremented we'll have the same value. }


But this implementation is very inefficient.

-nuffin
zz zZ Z Z #!perl