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

Re: How to check whether an element is present in an array of array

by irah (Pilgrim)
on Jun 05, 2009 at 10:44 UTC ( [id://768749]=note: print w/replies, xml ) Need Help??


in reply to How to check whether an element is present in an array of array

The direct answer available in perldoc.

@mainarr = (1, 2, 3, 4, 5, 6,7, 8, 9, 10, 11, 12, 13, 14, 15); @is_tiny_prime = (); for (@primes) { $is_tiny_prime[$_] = 1 } # or @istiny_prime[@primes] = (1) x @primes;

Now you check whether $is_tiny_prime[$some_number].

If the number available in array, it print 1, else 0.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-24 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found