Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Matching an integer between 0 and 100

by Anonymous Monk
on Sep 01, 2009 at 17:50 UTC ( #792706=note: print w/ replies, xml ) Need Help??


in reply to Matching an integer between 0 and 100

I know this doesn't really answer your question, but in any real world situation, for this type of problem I'd generally solve the two criteria separately for maximum re-usability and adaptability.

Data::Validate has more robust implementations of both of these functions

if ( is_integer($value) && is_between_inclusive($value,0,100) ){ ... } sub is_integer{ my $value = shift; return $value =~/^[-]?\d+$/; } sub is_between_inclusive{ my ($value,$min,$max) = @_; return(($value >= $min) && ($value <= $max)); }


Comment on Re: Matching an integer between 0 and 100
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2015-07-04 01:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls