SyntaxFix
Write A Post
Hire A Developer
Questions
Check out the CPAN module Regexp::Common. I think it does exactly what you need and handles all the edge cases (e.g. real numbers, scientific notation, etc). e.g.
use Regexp::Common; if ($var =~ /$RE{num}{real}/) { print q{a number}; }