Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Is this an anomaly, and if so, where do I report it?

#!c:/perl
use strict;
use warnings;
my $out = {
result => 'error',
errors => [
'AB1'
]
};
# The following statement produces a warning and gives the wrong result
my $andresult = $out->{result} eq 'error' and $out->{errors}->[0] eq 'BC2';
# The following statement produces no warning and gives the correct result
my $ampampresult = $out->{result} eq 'error' && $out->{errors}->[0] eq 'BC2';
$andresult += 0;
$ampampresult += 0;
print "result using 'and': $andresult\n";
print "result using '&&': $ampampresult\n";
1 person has
this question
+1
Reply