use strict; use warnings; while () { if (/^(10|\d)$/) { print "Match for $_"; } else { print "Rejected $_"; } } __DATA__ 0 1 9 10 11 20 99 100 #### Match for 0 Match for 1 Match for 9 Match for 10 Rejected 11 Rejected 20 Rejected 99 Rejected 100 #### 0.1 01 1 1.0 1.01 9.9 10 10.0 10.01 11 20 99 100 #### Match for 0.1 Match for 01 Match for 1 Match for 1.0 Match for 1.01 Match for 9.9 Match for 10 Match for 10.0 Rejected 10.01 Rejected 11 Rejected 20 Rejected 99 Rejected 100