Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: How Much Is Too Much (on one line of code)?

by Limbic~Region (Chancellor)
on Jun 18, 2007 at 12:39 UTC ( #621776=note: print w/replies, xml ) Need Help??


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

Ovid,
I really don't think the second line is "too much" but it doesn't seem like a good idea either. It seems like the right thing to do would be to overload the country() method and abstract away the problem. Obviously that might not be possible given how country() is used elsewhere in the code.

An alternative might be:

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

Cheers - L~R

Replies are listed 'Best First'.
Re^2: How Much Is Too Much (on one line of code)?
by duckyd (Hermit) on Jun 21, 2007 at 02:35 UTC
    Since we're nitpicking a bit, I'll mention that I was wondering when this layout of the ternary operator would appear :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://621776]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2017-10-24 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (286 votes). Check out past polls.

    Notices?