develooper Front page | perl.perl5.porters | Postings from May 2013

Re: [perl #59802] return 0 or die;

From:
Miles Gould
Date:
May 1, 2013 17:58
Subject:
Re: [perl #59802] return 0 or die;
Message ID:
517E4B68.7080602@assyrian.org.uk
On 19 Feb 2013 at 17:07:05, Jan Dubois wrote:
 > Just for the record, I've also seen
 >
 > return foo() and bar(); # supposed to return TRUE only when
 > both foo() and bar() are true

I ran into this problem last night. The offending line was

return ($self->true_count($idx) > 0) xor ($self->false_count($idx) > 0);

and in this case it's easy to explain what I had in mind: I wanted my 
function to return the logical xor of those two expressions! Once I'd 
tracked the problem down it was easy enough to fix by reparenthesising, 
but a warning would have been very useful.

Miles



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About