in reply to number regex (incl sci notation)

This is a faq. Try some of the other possibilities listed from perldoc -q number.

My personal recommendation is to use Scalar::Util. It includes a routine looks_like_number that will handle anything that Perl thinks is a number.

Replies are listed 'Best First'.
Re^2: number regex (incl sci notation)
by jim_neophyte (Sexton) on Dec 07, 2004 at 20:16 UTC
    thanks for the assist. i had forgotten about the "perldoc -q" thing. also, the Scalar::Util qw( looks_like_number ) works wonderfully in my quick testing. thanks again.
Re^2: number regex (incl sci notation)
by rrwo (Friar) on Dec 07, 2004 at 20:21 UTC

    Scalar::Util's looks_line_number() routine checks the Perl API Looks Like Number field in the scalar.

    In some cases your variable might have a string which is a valid number, but doesn't have that field set.

      There is no "looks like a number field" in a scalar. looks_like_number() checks whether a *string* *looks like a number*. This is independent of whether the scalar has an IV stored in it (which appears to be what you are thinking of).

      - tye