$totalNumber = sprintf "%02d", 1; if($totalNumber =~ /^\d{2}$/){ if($totalNumber <= 10){ print "the number is less than 10\n"; } }