This will match empty string '', '..' and other non-numeric strings,
but will not match -1, 1.2e2, etc.

You better look in Perl Cookbook, Chapter 2, page 44.



-----Original Message-----
From: Ian Harisay [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 28, 2003 3:36 PM
To: Gregg Allen; [EMAIL PROTECTED]
Subject: Re: Determining return type in Perl/MySQL


I read the other responses.  It is hard to determine what is happening 
without seeing some code.  but to simply determine if something is a 
numeric value on could just use a regular expression:

($rv) = $sth->fetchrow_array();

if( $rv =~ /^[^0-9\.]*$/ ){  #-- the regex will work with unformatted 
integers and floating points.
  #-- do something because I don't have a numeric value.
}



Gregg Allen wrote:

>
> I have a complex,  prewritten subroutine that is supposed to return a 
> numeric value from a MySQL database table.  it actually works quite 
> well, most of the time, but sometimes it returns an undefined value, a 
> non-numeric value, or basically anything except a valid numeric value.
>
> This is OK in the sense that it just means they are records to be 
> ignored, but I am having trouble figuring out how to determine if it 
> is just a simple numeric value or a string or null, or whatever, so I 
> can decide how to process it.
>
> Any Suggestions?
>
> Thanks in Advance,
>
>
> Gregg Allen
>
>
>
>
>


Reply via email to