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
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |