Without wanting to be influenced by the other comments, my opinion is that it's too much, without braces or a comment to make it clear in what order things happen, or why they are happening.

Without the braces I probably have to .. no, I have to look up what the precedence order is, or try it in the debugger. Yes, certainly after developing in Perl for ten years I should probably know that, but I don't. Also, the assignment to $country followed immediately by a re-assignment to $country isn't a style I love.

OK, (after trying it in the debugger) it does do the ternary first and the if statement within that .. that's what I expected.

To answer your question, no, this code is not clear.

Was there a comment explaining the business logic? The left side of my brain suggests ..

# Blank country field if Great Britain, otherwise upper # case country name within square brackets. Leave field # empty if country is undefined.
.. but the right side of my brain prevails, and provides a much better comment:
# Since we're mailing from GBR, only display the country # if it's not GBR, and leave a blank country field blank.

Above all, strive for clarity.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds


In reply to Re: How Much Is Too Much (on one line of code)? by talexb
in thread How Much Is Too Much (on one line of code)? by Ovid

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.