Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Answer: How do I completely remove an element from an array?

by Minok (Novice)
on Apr 23, 2009 at 00:05 UTC ( [id://759447]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    foreach my $item ( (@array1, @array2) ) {
       if ( $item =~ /$pattern/i ) {
          @array1 = grep { $_ != $item } @array1;
       }
    }
    
  2. or download this
    my @toRemove;
    foreach my $item ( (@array1, @array2) ) {
    ...
    foreach my $item ( @toRemove ) {
       @array1 = grep { $_ ne $item } @array1;
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2024-10-07 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (44 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.