Re: Your Favorite Options for Perltidy
by Aristotle (Chancellor) on Nov 05, 2005 at 16:28 UTC
|
$ cat .perltidyrc --indent-columns=4
--continuation-indentation=4
--maximum-line-length=80
--entab-leading-whitespace=4
--tabs
--paren-tightness=0
--brace-tightness=0
--block-brace-tightness=0
--square-bracket-tightness=0
--nooutdent-long-quotes
--indent-spaced-block-comments
--outdent-long-comments
--long-block-line-count=4
--maximum-consecutive-blank-lines=2
#=--standard-output
#=--standard-error-output
Makeshifts last the longest. | [reply] [Watch: Dir/Any] [d/l] |
Re: Your Favorite Options for Perltidy
by sauoq (Abbot) on Nov 05, 2005 at 16:10 UTC
|
$ cat .perltidyrc
-ce
-nsfs
-isbc
-olc
-sauoq
"My two cents aren't worth a dime.";
| [reply] [Watch: Dir/Any] [d/l] |
Re: Your Favorite Options for Perltidy
by borisz (Canon) on Nov 05, 2005 at 17:30 UTC
|
-l=80 -ci=2 -i=2 -lp -nsfs -bar -bbb -bbs -bbc -anl
| [reply] [Watch: Dir/Any] |
Re: Your Favorite Options for Perltidy
by pboin (Deacon) on Nov 06, 2005 at 00:52 UTC
|
| [reply] [Watch: Dir/Any] |
|
Thanks so much.
But when does .perltidyrc get executed?
- automatically when we start a perl script? or
- when we pass the command: $ perltidy myfile.pl ?
| [reply] [Watch: Dir/Any] [d/l] [select] |
|
Nothing's *automatic* per se. Perltidy is a filter that you run on source. As TheDamian has it setup, it will print to STDOUT, so you can do something like this:
perltidy sloppy_format.pl > cleaned_up.pl
.perltidyrc will be automatically called for configuration details. Once you get that figured out, you can even hightlight one block in vim and do "! perltidy" to cleanup just a block within a file.
Good luck and perservere. Tidy code is a worthwhile endeavor, whether you create it that way or beat it into submission with a tool.
| [reply] [Watch: Dir/Any] [d/l] |
Re: Your Favorite Options for Perltidy
by ambrus (Abbot) on Nov 05, 2005 at 15:56 UTC
|
I don't use perltidy. I do the formatting by hand, with some help from the editor.
| [reply] [Watch: Dir/Any] |
|
Missing right curly or square bracket at ccpd.pl line 1102, at end of
+line
syntax error at ccpd.pl line 1102 at EOF
Bugger. So where is the missing curly brace? Dunno. Have no fear, for Perltidy will tell me in the error file it creates.
The most recent un-matched '{' is on line 567
567: sub createAuthMessage {
Now that rocks.
| [reply] [Watch: Dir/Any] [d/l] [select] |
|
An editor can help there too: I jump to the EOF where the error appears, insert a closing brace, and jump to the matching brace.
However, an even more efficent way to find the missing braces is when the interpreter guesses its place from the indentation of the code (even though the indentation has no semantical meanning). The MzScheme interpreter can do this, and usually guesses right. (I hope perl6 will be able to do this too.) If, however, you reformat the code with an indenter, then the indents will follow the braces you've put there, not the way you think the code should be indented, so then indentation can't provide a clue to the interpreter.
| [reply] [Watch: Dir/Any] |
|
That rocks indeed! What command do you use to generate that last message? And in what environment?
| [reply] [Watch: Dir/Any] |
|
Re: Your Favorite Options for Perltidy
by Anonymous Monk on Oct 23, 2009 at 07:05 UTC
|
perltidy now comes with option
-pbp, --perl-best-practices
-l=78 -i=4 -ci=4 -st -se -vt=2 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -n
+sfs -nolq
-wbb="% + - * / x != == >= <= =~ !~ < > | & =
**= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x="
| [reply] [Watch: Dir/Any] [d/l] |
Re: Your Favorite Options for Perltidy
by mje (Curate) on Oct 23, 2009 at 09:42 UTC
|
$abcde = 1;
$b = 1;
but by default I get;
$abcde = 1;
$b = 1;
| [reply] [Watch: Dir/Any] [d/l] [select] |