http://qs1969.pair.com?node_id=1079930


in reply to conditional statements in list constructors

... the tertiary conditional is an if statement(term/expression), wrapped in a do block.

The "tertiary conditional" is a conditional expression: it evaluates to one thing or else another thing. It may produce an effect like that of a  do { ... } block, but I would say it is incorrect to say it is a do-block. (Update: E.g., the  + operator produces a result like that of a do-block with some arithmetic operations in it, but it makes no sense to say it is a do-block.) What does the decompiler say?

Update: Added example. (Update: Changed example to include do-block in list.)

c:\@Work\Perl\monks>perl -wMstrict -le "my $x = 1; ;; my @ra = ( 'x', $x ? 'foo' : 'bar', 'y', do { if ($x) { 'biz' } else { 'boz' } } ); print qq{@ra}; " x foo y biz c:\@Work\Perl\monks>perl -wMstrict -MO=Deparse,-p -le "my $x = 1; ;; my @ra = ( 'x', $x ? 'foo' : 'bar', 'y', do { if ($x) { 'biz' } else { 'boz' } } ); print qq{@ra}; " BEGIN { $^W = 1; } BEGIN { $/ = "\n"; $\ = "\n"; } use strict 'refs'; (my $x = 1); (my(@ra) = ('x', ($x ? 'foo' : 'bar'), 'y', do { if ($x) { 'biz'; } else { 'boz'; } })); print("@ra"); -e syntax OK