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 kesterkester (Hermit)
on Aug 30, 2004 at 22:57 UTC ( [id://387061]=note: print w/replies, xml ) Need Help??


in reply to writing perl function like sql IN

The PDL modules have something like this: perl -MPDL -e '$in = pdl 0..100; $x = 10; print where ( $in, $in == $x )', or you could roll your own with something like this:

#!/usr/local/bin/perl use warnings; use strict; sub in { my ( $x, @args ) = @_; foreach ( @args ) { return 1 if $_ == $x; } return 0; } print ( "\nyes: ", in (10, 8..12) ); print ( "\nno: ", in (10, 11..120) )

Log In?
Username:
Password:

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

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

    No recent polls found