Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 ( #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.


Comment on Re^2: Best practices and any way to have Perl Tidy clean it up
Select or Download Code
Re^3: Best practices and any way to have Perl Tidy clean it up
by hdb (Prior) 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)

Re^3: Best practices and any way to have Perl Tidy clean it up
by fishmonger (Pilgrim) 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);

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-09-17 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (89 votes), past polls