This is much faster and more accurate:

        if ( DBI::looks_like_number($rv) ) {
            ...
        }

Uses perl's own internal code.

Tim.

On Wed, May 28, 2003 at 02:36:26PM -0600, Ian Harisay wrote:
> 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