[EMAIL PROTECTED] wrote:
> Hi folks,
>
> I have a seemingly simple problem, but I can't find a satisfying
> solution. I have a function which tests to see if a value represents
> what I want to call "true". Here's a simplified version:
>
> if ($val =~ /true/i || $val =~ /t/i || $val != 0) { return 1; }
> else { return 0; }
>
if ( $val =~ /^\d+$/ and $val ) {
return 1;
}else {
return 0;
}
Can you have + or - within (as -2) or how about decimal point(is 12.1)
then you would need to address this also.
Looks like you are after positivie integer without sign, but that is only from
what you have presented.
> The text might be numeric or not. If it is numeric, I want to accept
> anything but zero as true. But, if I run this on a textual non-true
> value, such as "false", I get:
>
> Argument "false" isn't numeric in numeric ne (!=) at ...
>
> The code works, but I don't want to get the warning (I'm using
> 'warnings'). So, how can I test to see if it's a numeric value,
> before I try to use it as one? I tried using int() to convert it,
> but that gives the same warning.
>
> Any ideas? Thanks.
*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs