Re: Zero equals pipe??
- From: John Bokma <john@xxxxxxxxxxxxxxx>
- Date: 24 Sep 2006 01:58:04 GMT
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.
== is for numbers, eq is for strings, which makes sense.
What makes even more sense, if you're a newbie to Perl, put on top of your
script:
use strict;
use warnings;
Since then you would have seen:
Argument "|" isn't numeric in numeric eq (==)
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
.
- References:
- Zero equals pipe??
- From: ilya2
- Zero equals pipe??
- Prev by Date: FYI: Something I saw on generating random-numbers
- Next by Date: Re: Zero equals pipe??
- Previous by thread: Re: Zero equals pipe??
- Next by thread: Re: Zero equals pipe??
- Index(es):
Relevant Pages
|