Given the above, here's a step by step breakdown of what Perl does.
c: When the code is compiled. r: When the code is run. my @list = x() | (1,2,3); c => my @list = scalar(x()) | scalar(1,2,3); c => my @list = scalar(x()) | scalar(2,3); <<void warn>> c => my @list = scalar(x()) | scalar(3); <<void warn (supressed)>> c => my @list = scalar(x()) | 3; r => my @list = undef | 3; r => my @list = 0 | 3; <<uninit warning>> r => my @list = 3; my @list0 = x() || (1,2,3); c => my @list0 = scalar(x()) || (1,2,3); r => my @list0 = undef || (1,2,3); r => my @list0 = (1,2,3); my @list1 = x() or (1,2,3); c => ( my @list1 = x() ) or (1,2,3); c => ( my @list1 = x() ) or (2,3); <<void warn>> c => ( my @list1 = x() ) or 3; <<void warn (supressed)>> c => my @list1 = x(); <<void warn>> r => my @list1 = (); my @list2 = $c->bbox('all') || (1,2,3); c => my @list2 = scalar($c->bbox('all')) || (1,2,3); r => my @list2 = [ ... ] || (1,2,3); r => my @list2 = [ ... ]; my @list3 = $c->bbox('all') or (1,2,3); c => ( my @list3 = $c->bbox('all') ) or (1,2,3); c => ( my @list3 = $c->bbox('all') ) or (2,3); <<void warn>> c => ( my @list3 = $c->bbox('all') ) or 3; <<void warn (supressed)>> c => my @list3 = $c->bbox('all'); <<void warn>> r => my @list3 = ( ... );
In reply to Re^2: 'or' versus '||' - Unexpected Results
by ikegami
in thread 'or' versus '||' - Unexpected Results
by cmv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |