Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Code requested for array intersection count

by Fletch (Bishop)
on Jun 09, 2003 at 15:25 UTC ( [id://264353]=note: print w/replies, xml ) Need Help??


in reply to Code requested for array intersection count

Strictly speaking he doesn't want the intersection. He wants to put the elements from @array_2 into a bag (Set::Bag) but only if they're present in @array_1.

my %wanted = map { $_, 1 } @array_1; my $bag = Set::Bag->new( ); foreach( @array_2 ) { $bag->insert( $_ => 1 ) if $wanted{ $_ }; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found