in reply to vallidating a regular expression

The regex /^\d{2}$/ specifies exactly 2 digits (see perlre for more information about using curlies as quantifiers). Changing it to /^\d\d?$/, which means one digit followed optionally by another digit, or /^\d{1,2}$/, which specifies either one or two digits, give the results you want.

Note that this regex works only for integers. Numbers containing decimal points (such as 2.0) will fail.

Additionally, there is an extra opening parenthesis in your 'if' statement. use warnings; would have alerted you to the syntax error.