On Tue, Mar 4, 2008 at 4:44 PM, Randal L. Schwartz
<[EMAIL PROTECTED]> wrote:
> >>>>> ""Andrew" == "Andrew Curry" <[EMAIL PROTECTED]> writes:
>
>  "Andrew> If you are not 100% sure then you can also do if ($x =~/^\d*$/) for 
> an
>  "Andrew> actual integer i.e. a number in the positive whole set of numbers {
>  "Andrew> 1,2,3....}  or negative whole numbers -1,-2,-3.... or 0.
>
>  This also fails, declaring "123\n" as a match, and thus being
>  "an integer".  False positive.
>
>  Please check your answers before answering on beginners next time.
snip

That depends on what the current definition of integer is.  If by
integer the original poster meant treated like an integer by Perl then
"123\n" can be seen as an integer.  Of course, in that case "123foo"
is also an integer and would fail the check (false negative).  In any
case, it is important to be very clear in what you mean, and the best
way to be clear is to use a regex like /\A[0-9]+\z/ or a pseudo-regex
like "composed of only the characters 0 through 9 one or more times".

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to