It's a precedence problem.
B::Deparse with the -p option can show you how Perl understands expressions. Unfortunately, the expression contains only constants, so it's evaluated at compile time, so the result isn't helpful:
$ perl -MO=Deparse,-p 1.pl
use strict;
my($test);
($test = (undef));
print("test = $test\n");
1.pl syntax OK
You need to introduce variables to postpone the evaluation to runtime to get a more enlightening answer:
#! /usr/bin/perl
use warnings;
use strict;
my $test;
my $undef;
my $true = 1;
my $zero = 0;
$test = $true || ($undef && $undef != $zero) ? $undef : $zero;
print "test = $test\n";
And, voilą:
use strict;
my($test);
my($undef);
(my $true = 1);
(my $zero = 0);
($test = (($true || ($undef && ($undef != $zero))) ? $undef : $zero));
print("test = $test\n");
1.pl syntax OK
Nicely indented:
$test = (
(
$true || (
$undef && (
$undef != $zero
)
)
) ? $undef : $zero
)
$true || ... returns 1, so the "then" part of the ternary is returned, i.e. $undef.
Maybe you wanted
$test = $true || ($undef && $undef != $zero ? $undef : $zero);
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
}map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|