in reply to Re: Warning-free numerification of a string
in thread Warning-free numerification of a string

Sound advice ... now how would I go about "checking the input matches my expectations", those being that it should be a number, or else converted to zero (preferably without turning off warnings to do so). Ah yes, back to the original question then :-)
  • Comment on Re^2: Warning-free numerification of a string

Replies are listed 'Best First'.
Re^3: Warning-free numerification of a string
by clinton (Priest) on Aug 08, 2007 at 19:24 UTC
    Either with Fletch's suggestion of looks_like_number from Scalar::Util, or a regex from Regexp::Common, or if actually, you're just expecting a positive integer, a simple regex like  /^\d*$/