Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Best practices and any way to have Perl Tidy clean it up

by walkingthecow (Friar)
on Apr 13, 2013 at 14:22 UTC ( [id://1028521]=note: print w/replies, xml ) Need Help??


in reply to Re: Best practices and any way to have Perl Tidy clean it up
in thread Best practices and any way to have Perl Tidy clean it up

Alright, assuming Perl Tidy cannot do this, then my next question is, what are the best practices for object parameters? For example:
my $blah=$ldap->new( PARAM1 => $param1, PARAM2 => $param2, PARAM3 => $param3, );
or:
my Ssth = $dbh->prepare( "SELECT * FROM DATABASE WHERE name = '$name' AND money = '$money' AND field = '$field' ");
I'm trying to get a feel for how deal with this formatting. Amount of spaces for what's within the parentheses; do the parentheses line up? And so on. I know it's a rather stupid question, but after all these years it's something that is still bothering me. I format everything else beautifully, but when it comes to this I have always been rather clueless.

Replies are listed 'Best First'.
Re^3: Best practices and any way to have Perl Tidy clean it up
by fishmonger (Chaplain) on Apr 13, 2013 at 14:47 UTC
    Since this is for the most part a personal preference there is no single correct answer, but my choice of formatting usually goes like this:
    my Ssth = $dbh->prepare(q( SELECT * FROM DATABASE WHERE name = ? AND money = ? AND field = ? )); $sth->execute($name, $money, $field);
Re^3: Best practices and any way to have Perl Tidy clean it up
by hdb (Monsignor) on Apr 13, 2013 at 14:37 UTC

    To be honest, I place the parantheses like you do, and leave the rest to Emacs' Perl mode.

      Additionally cperl-mode has a command to wrap long regions mapped on M-q plus an extra cperl-fill-paragraph command for comments.

      I rarely use perl-tidy, emacs has almost all of it included.

      And this kind of formatting can at best be semi-automatic since human monitoring is needed.

      Cheers Rolf

      ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-24 12:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found