Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: writing perl function like sql IN

by dave_the_m (Monsignor)
on Aug 30, 2004 at 22:57 UTC ( [id://387062]=note: print w/replies, xml ) Need Help??


in reply to writing perl function like sql IN

if (grep $x == $_, 1, 3, 7) { ... }

Dave.

Replies are listed 'Best First'.
Re^2: writing perl function like sql IN
by eserte (Deacon) on Aug 31, 2004 at 13:39 UTC
    A slightly more efficient solution (see the discussion below) would use the standard List::Util::first function:
    if (defined first { $x == $_ } 1, 3, 7) { ... }
    Note that it is necessary to use defined(), as first() returns the first matching element (which may be zero), not a list.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-03-29 14:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found