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

Re: how to quickly tell if number is in an array

by Rajeshk (Scribe)
on Oct 12, 2005 at 10:31 UTC ( [id://499445]=note: print w/replies, xml ) Need Help??


in reply to how to quickly tell if number is in an array

Hi,

Try this code..
@a = (1,3,5);
$number = 3;

if((grep /$number/, @array)){
print "Found";
}else{
print "Not Found";
}


Thanks
Rajesh.K
  • Comment on Re: how to quickly tell if number is in an array

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-23 15:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found