| From | Sent On | Attachments |
|---|---|---|
| Donnie Jones | Jun 29, 2002 6:02 pm | |
| John W. Krahn | Jun 29, 2002 6:15 pm | |
| Shawn | Jun 29, 2002 8:06 pm | |
| Tara Calishain | Jun 29, 2002 8:49 pm | |
| Timothy Johnson | Jun 29, 2002 11:13 pm | |
| Timothy Johnson | Jun 29, 2002 11:20 pm | |
| Timothy Johnson | Jun 29, 2002 11:30 pm | |
| Connie Chan | Jun 30, 2002 12:02 am | |
| Donnie Jones | Jun 30, 2002 3:08 pm | |
| John W. Krahn | Jun 30, 2002 4:28 pm | |
| Donnie Jones | Jun 30, 2002 4:50 pm | |
| Timothy Johnson | Jun 30, 2002 9:57 pm | |
| Tim Maher/CONSULTIX | Aug 23, 2002 10:02 am |
| Subject: | RE: Check for integer | |
|---|---|---|
| From: | Timothy Johnson (tjoh...@sandisk.com) | |
| Date: | Jun 29, 2002 11:30:52 pm | |
| List: | org.perl.beginners | |
Of course, once again I forgot to explain myself.
/^(+|-)?\d+$/ means:
/^ : Starting at the beginning of the variable (+|-) : '+' or '-' (see next line) ? : Match zero or one of the above character \d+ : Followed by one or more digits $/ : Followed by the end of the variable
-----Original Message----- From: Timothy Johnson To: 'Shawn '; 'Donnie Jones '; 'begi...@perl.org ' Sent: 6/29/02 11:20 PM Subject: RE: Check for integer
Except that their checking for an integer, so it's even simpler than that.
if($scalar =~ /^(+|-)?\d+$/){ print "It's an integer!\n"; }
Will check for an integer, with or without a plus or minus sign.
-----Original Message----- From: Shawn To: Donnie Jones; begi...@perl.org Sent: 6/29/02 8:07 PM Subject: Re: Check for integer
----- Original Message ----- From: "Donnie Jones" <donn...@yahoo.com> To: <begi...@perl.org> 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





