Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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 scrutinizing the Monastery: (4)
As of 2018-06-23 03:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (125 votes). Check out past polls.

    Notices?