|Just another Perl shrine|
Re: conditional statements in list constructorsby Don Coyote (Hermit)
|on Mar 28, 2014 at 01:10 UTC||Need Help??|
Thanks for clarifying my use of conditional. The question has been answered expertly. I did mean to write compound rather than conditional though. my bad:\
great insights, I have not seen the x!!() operator before.
My question, wrongly put, is really in the second paragraph, why does the if compound statement not compile in list constructors?
using MO=Deparse showed me the if compound statement reduces to a do block so I can take some comfort in my not quite correctly placed assumptions. That is, I was trying to use the if statement as a conditional or rvalue, within a list constructor, when it simply is not one.
The reason for me showing the examples, was to show that context did not make a difference in the syntax compilation, in case that did have a relevance, unfortunately my miss-worded question let me down here.
I was just confused by an if statement not compiling within a list context.
So while thanking you for reminding me about the particular instance of taking a ref to a list, which you will be glad to know, has now sunk in, the if statement within the list does not actually compile. Should it have done in the way the ternary conditional does, then I am sure there are cases where taking refs to the last item in the resultant list do come in useful.
And look, if the vogons recite the virtues of tertiary operators in the poetic redrafts of high order mouse manuals volumes XXXII thru VL then who or what am I to argue?...ahem,oops