use Regexp::Common qw /number/; my $ok = $num =~ /^$RE{num}{real}$/ && 0 <= $num && $num < 1 ;