On Wed, 30 Aug 2006 15:44:53 -0700 (PDT)
"Mary Anderson" <[EMAIL PROTECTED]> wrote:

> 
> Hi All,
>    I know this isn't strictly a cgi problem, but it is arising in a cgi 
> application.  I have a loop which reads certain fields, hashed on names.
> Some of my fields hold character strings, some hold numbers.  Sometimes 
> the number field is a blank.  I need a test on the field value $fieldValue 
> which will tell me if my field was blank regardless of whether it holds a 
> character string or a number.
> 
>       I would like to say something like
> 
>   $fieldValue = (($fieldValue == 0) or $fieldValue) ? $fieldValue : 'null'
> 
> but perl appears to have a strange interpretation of $fieldValue == 0 if 
> $fieldValue is a character.
> 
> Thanks
> Mary
> 
>      I have seen references to a function which will do the trick, but it 
> is not mentioned in the camel book.


You need to use 'eq' or 'ne' for strings. 0 isn't a string. So you have to 
rethink your logic

Look up comparison, relational and equality operators. Try perldoc perlop (not 
sure)



Owen

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to