Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: subtract one array from another

by demerphq (Chancellor)
on Oct 17, 2002 at 12:25 UTC ( #205999=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %hash;
    $hash{$_}=1 foreach @array_1;
    @array_2=grep($hash{$_},@array_2);
    
  2. or download this
    #for (my $search =0; $search<scalar @array1; $search++) # blech, this 
    +isnt C you know
    for my $search (0.. $#array1)                           # ahhh thats m
    +uch better
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://205999]
help
Chatterbox?
[Corion]: 1nickt: Would be great, especially for naming parameters in @_.
[Corion]: When you pass an arrayref, you get to treat it like a local array. But then, I'm cautious with the experimental features, because just when I thought function signatures were a set thing, there is a proposal to use sub [ $foo, $bar ] { ... } to ...
[Corion]: ... declare the parameters, instead of the more common sub ($foo, $bar) { ... }

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2017-11-17 20:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (272 votes). Check out past polls.

    Notices?