Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Comparing Arrays -> storing results in a third Array

by DamnDirtyApe (Curate)
on Aug 15, 2002 at 03:27 UTC ( #190288=note: print w/replies, xml ) Need Help??


in reply to Comparing Arrays -> storing results in a third Array

I'd agree with using grep, though I'd use a hash rather than a regexp.

my @array_1 = qw( x y z ) ; my @array_2 = qw( v w x ) ; my %base = map { $_ => 1 } @array_1 ; my @intersection = grep { $base{$_} } @array_2 ;

_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
            --Friedrich Nietzsche

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2020-03-30 11:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (175 votes). Check out past polls.

    Notices?