http://qs321.pair.com?node_id=1010671


in reply to Removing elemets from an array

The hint to perlfaq4 is excellent.

Use a hash and grep() and you are fine. No need for delete() or splice() here.

#! /usr/bin/perl use strict; use warnings; my @arcb = ( 450, 625, 720, 645 ); my @arca = ( 625, 645 ); ### see perlfaq4 - How can I remove duplicate elements from a list or +array? my %unwanted; ### or %seen as in the faq4 $unwanted{$_}++ for @arca; @arcb = grep { !$unwanted{$_} } @arcb; print "@arcb\n"; + __END__

Updates