http://www.perlmonks.org?node_id=792706


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)); }