I've read the FAQ's on this, but they don't seem to answer the question.

I have a variable that could contain any value( alpha, alpha-numeric, or
numeric). If the value is NOT numeric, I need to change the variables' value
to "0"( as in zero ).

Examples:
$txtype="2.314";   # is numeric, so keep the value
$txtype="-2.314";  # is numeric, so keep the value
$txtype="7";       # is numeric, so keep the value
$txtype="-7";      # is numeric, so keep the value
$txtype="2.31.4";  # is not numeric, so change the value to 0
$txtype="7-7";     # is not numeric, so change the value to 0
$txtype="UNKNOWN"; # is not numeric, so change the value to 0
$txtype="7+E09";   # is not numeric( even though it really is ), so change
the value to 0


My guess is that I need a regex that will match on any character that is:
        not 0-9 
        or 
        more than one "." 
        or 
        more than one "-" 
        or if "-" is not the first character of the string

Any ideas? Is it possible to do without using additional modules?

Thanks!

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to