#!/usr/bin/perl -w use strict; use Dumpvalue; my $d = new Dumpvalue; #testing my @ArrayA = (0 .. 100); print "before\n"; $d->dumpValues(\@ArrayA); print "\n"; #more testing. my @numbers_to_remove = (14 .. 36, 50 .. 63, 89, 91, 94); #here we reassign @ArrayA with the return value from #our do{} block. @ArrayA = do { #make a local copy of @ArrayA as is to begin with my @tmp = @ArrayA; #map returns a list which comes in handy here map{ #make a local copy of the incoming elements from #our local copy in @tmp my $key = $_; #use a ternary operator to make sure we are #not including numbers from our #@numbers_to_remove list. If it is not #found return it otherwise return an #empty list. (!grep /^$key$/, @numbers_to_remove) ? $key : (); }@tmp; #for each element in @tmp }; print "After\n"; $d->dumpValues(\@ArrayA); print "\n";