----- Original Message ----- 
From: "Donnie Jones" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, June 29, 2002 8:03 PM
Subject: Check for integer


> Hello,

Hello Donnie,

> 
> I was wondering if anyone knows how someone can test the value held by a variable in 
>perl to see if it is an integer?
> 
> My current project is using the perl DBI, and I was users to enter data, but to make 
>sure that they don't enter strings
> in integer fields...

You can check the input like this:

unless($string=~/^\d+(\.\d+)$/) {
  error...
}

NOTE: This will not work for scientific notation, etc.

Shawn

> 
> 
> Please help.
> 
> Thanks,
> 
> --Donnie
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to