http://www.perlmonks.org?node_id=622189


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

I like this approach, too; the hash makes exceptions to the "uppercase bracket" basic rule perfectly clear. However, I also agree with other posters (1) treating $country as a temporary variable isn't great practice, and (2) it's not entirely clear what $card->country is allowed to return. Given those concerns, my own preference would be
my %exceptions = ('' => '', gbr => ''); my $c = $card->country || ''; my $country = exists($exceptions{$c}) ? $exceptions{$c} : uc "[$c]";