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

Re: Writing code that looks nice

by amir_e_a (Hermit)
on Apr 12, 2010 at 15:30 UTC ( #834296=note: print w/replies, xml ) Need Help??


in reply to Writing code that looks nice

I avoid using $_ and default arguments even in the shortest programs, except when i have to (in map, for example) or in very particular idioms, such as

for ($string) { s/^\s+//; s/\s+$//; }

(from perlfaq4.)

And i usually avoid postfix conditions.

But as everyone here says, it's a matter of taste.

Replies are listed 'Best First'.
Re^2: Writing code that looks nice
by Your Mother (Bishop) on Apr 12, 2010 at 16:11 UTC

    I think that's more idiomatic as

    s/\A\s+|\s+\z//g for @strings; # or $string =~ /\A\s+|\s+\z//g;

    For the OP: I prefer short, natural language code over formal blocks and such any day. But the point you get to at the bottom of it all is, there will be disagreement so consistency is best / don't edit other hackers' code for style; fit in with whatever codebase you have. (update, put in missing "/", thanks webfiend!)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://834296]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2019-12-08 16:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?