Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Checking for array entry in another array

by PrakashK (Pilgrim)
on Jul 26, 2001 at 20:13 UTC ( #100033=note: print w/ replies, xml ) Need Help??


in reply to Checking for array entry in another array

Hash slices can be handy here. I am using the example arrays from the categorized answer How can I find the union/difference/intersection of two arrays? Just replace @simpsons and @females with your arrays.

my @simpsons=("homer","bart","marge","maggie","lisa"); my @females=("lisa","marge","maggie","maude"); my %simpsons_hash; @simpsons_hash{@simpsons} = @simpsons; @female_simpsons = grep {$_} @simpsons_hash{@females};
HTH.


Comment on Re: Checking for array entry in another array
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2014-10-25 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (143 votes), past polls