Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Strange interaction between print and the ternary conditional operatorby WingedKnight (Novice) |
on Feb 20, 2020 at 03:17 UTC ( [id://11113223]=perlquestion: print w/replies, xml ) | Need Help?? |
WingedKnight has asked for the wisdom of the Perl Monks concerning the following question: Ran into a strange interaction between print and the ternary conditional operator that I don't understand. If we do...: print 'foo, ' . (1 ? 'yes' : 'no') . ' bar'; ...then we get the output...: foo, yes bar ...as we would expect. However, if we do...: print (1 ? 'yes' : 'no') . ' bar'; ...then we just get the output...: yes Why isn't " bar" getting appended to the output in the second case?
Back to
Seekers of Perl Wisdom
|
|