if ($b =~ /^\d$/ and $b > 0 and $b < 6) { ... }