Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How to find out if X is an element in an array?

by rajib (Novice)
on Aug 20, 2002 at 17:31 UTC ( #191525=note: print w/replies, xml ) Need Help??


in reply to How to find out if X is an element in an array?

$X = "x"; @array = ("y", "z", "x"); $i = 0; while (($i <= $#array && ($array[$i] ne $X)) { ++$i; } if ($i <= $#array) { # searched it & eureka return 1; # for true; } return 0; # for false;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2023-03-27 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (63 votes). Check out past polls.

    Notices?