Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Using IF and OR, I'm sure there is a better way

by bageler (Hermit)
on Dec 15, 2005 at 17:51 UTC ( [id://517043]=note: print w/replies, xml ) Need Help??


in reply to Using IF and OR, I'm sure there is a better way

write your own shortcircuiting any() if you don't want to use cpan:
sub any { my $var = shift; for (@_) { return 1 if $var == $_ } } if (any($var,1..2000)) { print "Var is between 1 and 2000 inclusive\n" + }

Replies are listed 'Best First'.
Re^2: Using IF and OR, I'm sure there is a better way
by cosmicperl (Chaplain) on Apr 27, 2008 at 18:37 UTC
    Think I like this one best. I'm sure it'll bench fastest as well. Firing up the regexp engine to compare will have a noticeable overhead.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 17:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found