jockel has asked for the wisdom of the Perl Monks concerning the following question:
Hi
Can someone please explain this behavior. I was surprised with result of the following code. (And please help me come up with a better Title for this question)
I think the variable $test should be set to $val1 (1) but instead it gets set to $val2 (undef)
#/usr/bin/perl use strict; my $test; $test = 1 || (undef && undef != 0) ? undef : 0; print "test = $test\n";
OUTPUT: test =
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mixing OR with conditional operator
by choroba (Cardinal) on Nov 19, 2017 at 10:28 UTC | |
by jockel (Beadle) on Nov 19, 2017 at 10:44 UTC | |
by LanX (Saint) on Nov 19, 2017 at 12:41 UTC | |
|
Re: Mixing OR with conditional operator
by BrowserUk (Patriarch) on Nov 19, 2017 at 10:21 UTC | |
by jockel (Beadle) on Nov 19, 2017 at 10:30 UTC | |
|
Re: Mixing OR with conditional operator
by Anonymous Monk on Nov 20, 2017 at 13:46 UTC | |
by Anonymous Monk on Nov 20, 2017 at 14:41 UTC | |
by soonix (Chancellor) on Nov 20, 2017 at 14:56 UTC | |
by Anonymous Monk on Nov 21, 2017 at 19:39 UTC |