in reply to Re: Style and warnings
in thread Style and warnings

There are perfectly valid numbers that Perl can deal with, even without warnings, which still contain non-digit characters. 1.3 comes to mind. And so do -5 and 3e5.

Furthermore, there are strings containing no \D characters, but which Perl cannot treat as numbers. "๑๒๓" for instance.

If you wish to find out whether a string looks like a number, use Scalar::Util::looks_like_number. Don't use simplistic regexes.

Replies are listed 'Best First'.
Re^3: Style and warnings
by BioLion (Curate) on Aug 18, 2009 at 17:40 UTC

    Just making an example. OP would have to make specific checks based on their input.

    You never know, maybe they are only dealing with integers, possibly joined with types of dog, in which case my example was perfect.

    Just a something something...
      You never know, maybe they are only dealing with integers, possibly joined with types of dog, in which case my example was perfect.
      Hmmm. Well, in that case, suppose the OP was dealing with a $seqnum equal to -9999997, in which case
      my $bigseqnum = 3;
      would have been perfect! You never know!

        The key point was *just an example*. i.e. Trying to make a point, rather than cover every base.

        Your points would be important checks to incorporate though, and OP should bear them in mind!

        Just a something something...