... 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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|