Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Removing certain elements from an array

by le (Friar)
on Aug 24, 2000 at 20:58 UTC ( [id://29457]=note: print w/replies, xml ) Need Help??


in reply to Removing certain elements from an array

My solution (clumsy as usual):
my @array = qw( ...); my @remindexes = qw( ... ); my %remindexes; my @newarray; for (@remindexes) { $remindexes{$_}++; } for (my $i = 0; $i <= $#array; $i++) { push @newarray, $array[$i] if !$remindexes{$i}; }
Of course, if you would setup the indexes to remove into a hash from the beginning, you could omit the first step.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://29457]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (None)
    As of 2025-01-13 09:40 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Which URL do you most often use to access this site?












      Results (28 votes). Check out past polls.