Re: Zero equals pipe??




ilya2@xxxxxxx wrote:
My perl program had some conditional statements that checked whether a
given characters was a pipe "|" or not. The program behaved strangely,
and I quickly realized it was treating pipes and zeros equivalently. To
make sure I was not going insane, I put the following checks:

if ( '1' == '|') { ... some statement ... }

if ( '0' == '|') { ... another statement ... }

By any sensible measure, both statements must return FALSE. First one
did that. Second one returned TRUE.

What's going on and how do I get around it?

My guess is that you do not want to do a numerical comparison.
Use 'eq' for a stringwise comparison.
Ken

.



Relevant Pages

  • Re: Zero equals pipe??
    ... given characters was a pipe "|" or not. ... and I quickly realized it was treating pipes and zeros equivalently. ... Second one returned TRUE. ... the numerical values of your three strings are ...
    (comp.lang.perl.misc)
  • Re: Zero equals pipe??
    ... given characters was a pipe "|" or not. ... and I quickly realized it was treating pipes and zeros equivalently. ... use warnings; ... Perl help, tutorials, and examples: http://johnbokma.com/perl/ ...
    (comp.lang.perl.misc)