No such thing as a small change | |
PerlMonks |
Re^3: Short form (ternary) if elseby DStaal (Chaplain) |
on Feb 09, 2012 at 21:40 UTC ( [id://952858]=note: print w/replies, xml ) | Need Help?? |
Yes and no... It is typically at it's most useful after an assignment, and it's use is that it generates a value, but that doesn't necessarily mean it needs to be used in an assignment. Others have given examples, but the essential thing to remember is that the ternary operator returns a value. if does not: It is a flow-control operator. So, where it does need to be used is where Perl would expect a value. Assignments are one common case of that.
In Section
Seekers of Perl Wisdom
|
|