my $country = $card->country; $country = $country eq 'gbr' ? '' : uc "[$country]" if $country;

Since this is very subjective, and the post somewhat of a poll, I'll add my opinion too: differently from most other people here I'm not the very least disturbed by the length of the second line, nor by the fact that as someone said, it "does two things in one statement". Yet I wouldn't do this particular thing in this particular way. Probably I'd pick some of the other alternative mentioned in this thread. Basically I would like the test for country to stay near to that for $country eq 'gbr'. Now that I think of it, I (almost) never do that, but just to mention another WTDI, I could even (slightly) abuse a map for that:

my ($country) = map {$_ and $_ eq 'gbr' ? '' : uc "[$_]"} $card->count +ry;

Or, since I prefer to use && to operate on values, perhaps

my ($country) = map $_ && ($_ eq 'gbr' ? '' : uc "[$_]"), $card->count +ry;

Update: added parentheses around $country above, as per Roy Johnson's remark. Perhaps when one is not used to abuse, he should not be tempted to do it...


In reply to Re: How Much Is Too Much (on one line of code)? by blazar
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.