now, the good news is Mr. Tarnary operator can be used in multi-statements unlike to what i usually hear about it (that it can only be used in single statement only).

Nope: the arguments to ?: are expressions, period. But then Perl also has operators/functions/constructs that let you "interpolate" a whole block of code containing multiple statements into a single expression. Thus you have two different tools that you can use synergetically together: this is nothing new - just build something complex out of simple pieces.

Update: (some philosophy) I've tried, along with others, to explain you that if, else, etc. on the one hand and ?: on the other one are different things with different purposes, although also with some overlapping. Now I'll try with an analogy: suppose you have both a pickup and a scooter available. Now, if you have a huge load to bring from some place to another place, you will probably use the former, but if it's a tiny package, the latter. Granted: nobody prohibits to you to also use the pickup to transport the tiny package nor to invent some smart binding that will allow you to put the huge load on the scooter. That is exactly what you're doing. There are languages in which you only have either the pickup or the scooter: in those cases you have to do it those ways. But Perl lets you decide: it lets you decide to pick up the best suited tool for any given job - and also the not best suited one, if you really insist to. That's part of its TMTOWTDIness.


In reply to Re^5: Mr. Ternary is greater than Mrs. If Else by blazar
in thread Mr. Ternary is greater than Mrs. If Else by PerlPhi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.