4

I am attempting to get perltidy to indent correctly. It works almost perfectly, but there are issues with some lines of code.

For example:

$foo = something()
   or Foo->throw(
   'a string which is longer than -l line length. Gets wrapped to next line, but not indented further than line above'
   );

which should be:

$foo = something()
   or Foo->throw(
       'a string which is longer than -l line length. Gets wrapped to next line, but not indented further than line above'
   );

Also, if a line break already exists, it does not get the indentation right:

$foo = something()
   or Foo->throw(
   'string'
   );

should be:

$foo = something()
   or Foo->throw(
       'string'
   );

Funnily enough, it gets it right if the function call contains a hashref...

The perltidyrc:

# Line
-l=78           # Max line width is 78 cols
-ole=unix       # Unix line endings

# Indentation
-i=4            # Indent level is 4 cols
-ci=4           # Continuation indent is 4 cols
-dt=4           # Default tab size is 4 cols
-noll           # Don't outdent long quoted strings or lines

# Comments
-iscl           # Ignore inline comment (side comments) length

# Blank lines
-blbs=1         # Ensure a blank line before methods
-bbb            # Ensure a blank line before blocks
-mbl=1          # Maximum consecutive blank lines

# Braces/parens/brackets
-nbl            # Opening braces on same line (incl. methods)
-pt=0           # Low parenthesis tightness
-sbt=0          # Low square bracket tightness
-bt=0           # Low brace tightness
-bbt=0          # Low block brace tightness

# Semicolons
-nsfs           # No space for semicolons within for loops
-nsts           # No space before terminating semicolons

# Spaces / Tightness
-baao           # Break after all operators
-bbao           # Break before all operators
-cti=0          # No extra indentation for closing brackets

# General perltidy settings
-conv           # Use as many iterations as necessary to beautify, until successive runs produce identical output (converge)
-b              # Backup files and modify in-place
-se             # Errors to STDERR

I've gone back and forth a lot with varying degrees of success, but not managed to get it exactly right. Any pointers?

bytepusher
  • 1,568
  • 10
  • 19

0 Answers0