I'm back...heh. I hope all this formats correctly for easy reading....
###########################################################
# Here's my code for this instance
#
if( $insert_field[$i] =~ /^(+|-)?\d+$/ ) ### Line 161
{
$sql .= qq{
$insert_field[$i]
};
$i++;
}
#
###########################################################
###########################################################
# I ran this to find the error hopefully....
#
perl -wc SPI-insert_data.pl
Useless use of a variable in void context at SPI-insert_data.pl line 104.
/^(+|-)?\d+$/: ?+*{} follows nothing in regexp at SPI-insert_data.pl line 161.
###########################################################
I am not sure what that error means... I did some searching on google to no
avail, please help.
If you would like, I can attach the whole file?
Thanks for all help.
--Donnie
On Sat, 29 Jun 2002 23:31:14 -0700
Timothy Johnson <tjohnson@xxxxxxxxxxx> wrote:
>
>
> 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 '; 'beginners@xxxxxxxx '
> 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; beginners@xxxxxxxx
> Sent: 6/29/02 8:07 PM
> Subject: Re: Check for integer
>
>
> ----- Original Message -----
> From: "Donnie Jones" <donniejones18@xxxxxxxxx>
> To: <beginners@xxxxxxxx>
> 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: beginners-unsubscribe@xxxxxxxx
> > For additional commands, e-mail: beginners-help@xxxxxxxx
> >
> >
> >
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
> For additional commands, e-mail: beginners-help@xxxxxxxx
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
> For additional commands, e-mail: beginners-help@xxxxxxxx
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
> For additional commands, e-mail: beginners-help@xxxxxxxx
|