Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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.