Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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 (Archbishop) 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?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2023-03-28 05:09 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (66 votes). Check out past polls.