use strict; my @a = (1..20); my @b = (2,3,13,14,17); @a = do{my %i; undef @i{@a}; delete @i{@b}; sort {$a<=>$b} keys %i}; #### use strict; #Lets say we have two arrays @a and @b #and we want to, as in your posting, remove the elements in @b #from those in @a my @a = (1..20); my @b = (5,8,13,16); #we in essence re-write the contents of @a with our map statement #that allows us to check the values for those we want to remove. @a = map{ my $i = $_; (grep /^$i$/, @b) ? () : $i ; }@a;