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

I wonder if you mean "too much in a line" or "too much in a statement"? We all know Perl doesn't mind newlines in a statement, so my personal rule that "seventy columns in a line is way too many" can help make the statement more comprehensible. Just add sensible phrasing and indentation.

The ". . . if $country" modifier can be removed, and the hard-coded 'gbr' with it, if we keep a hash of exceptions:

my %oddball = ( '' => '', gbr => '', ); my $country = $card->country; $country = exists $oddball{$country} ? $oddball{$country} : "[\U$country\E]";
Added: changed uc to a translation escape, just to be different.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: How Much Is Too Much (on one line of code)?
by demerphq (Chancellor) on Jun 18, 2007 at 16:25 UTC

    If you hadnt done it first I would have posted more or less the same thing.

    Although the evil part of me did think of writing a tied hash for this :-)

    ---
    $world=~s/war/peace/g

Re^2: How Much Is Too Much (on one line of code)?
by barrachois (Pilgrim) on Jun 20, 2007 at 06:56 UTC
    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]";