Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by GrandFather (Saint)
on Oct 12, 2005 at 01:30 UTC ( [id://499338]=note: print w/replies, xml ) Need Help??


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

my @array = (1, 2); print "found\n" if grep(3, @array);

which prints found may not be what OP expects


Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^3: how to quickly tell if number is in an array
by McDarren (Abbot) on Oct 12, 2005 at 02:23 UTC
    whoops!
    Okay... how about...
    print "found\n" if grep(/^$number\$/, @array);
      So now your using the regex engine.. to test if a number.. is exactly the same as another number?
        yes, this is a bit silly, isn't it.
        I just had a read of the faq on this one, and now I've realised that I need to go back and re-do a few of my utilty scripts...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 17:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found