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

Why isn't that just:

my $country = uc("[" . $card->country . "]"); $country = '' if $country eq "[GBR]";

___________
Eric Hodges

Replies are listed 'Best First'.
Re^2: How Much Is Too Much (on one line of code)?
by ysth (Canon) on Jun 18, 2007 at 18:02 UTC
    From the original code, it's clear that $card->country could be "", and, if so, shouldn't get brackets. But you've come closest to how I'd like to think I'd do it (assuming $card->country is always at least defined):
    my $country = uc("[" . $card->country . "]"); $country = '' if $country eq "[GBR]" || $country eq "[]";
    (This differs from the original if $card->country starts off as uppercase GBR, or if $card->country is 0 or undef or some overloaded object that acts false, but I'm guessing that's a good thing.)
Re^2: How Much Is Too Much (on one line of code)?
by Anonymous Monk on Jun 19, 2007 at 00:16 UTC
    If $card->country returns '0', your code sets $country to [0], while the original code sets it to 0.
Re^2: How Much Is Too Much (on one line of code)?
by demerphq (Chancellor) on Jun 19, 2007 at 13:16 UTC

    For one thing it would warn if $card->country() is undefined.

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