use Regexp::Common; while () { chomp; /^$RE{num}{real}$/ and print "$_ is a number\n"; } __DATA__ 123 abc 0.123