aflott has asked for the wisdom of the Perl Monks concerning the following question:

Is there an option for controlling how arguments are aligned?

e.g. I have this:

blah("whatever"); blah("this", "that", "more of this", "and another option that makes th +e line super looooooooong");

and want this:

blah("whatever"); blah("this", "that", "more of this", "and another option that makes the line super looooooooong");

I'd like the arguments to be put on new lines when they either a) reach a specific line limit b) is greater than n. Ideally I could get this with data structures as well.

This is the perltidyrc I'm using:

--indent-columns=4 # Indent 4 spaces --check-syntax # perl -c file for a second opinion --maximum-line-length=200 # Maximum line length --continuation-indentation=2 # Continuatioin indentation --nooutdent-labels # No outdenting of labels --paren-tightness=2 # Parens tightness --square-bracket-tightness=1 # Square bracket tightness --paren-tightness=2 # Brace tightness --nospace-for-semicolon # No for semicolon --space-after-keyword=1 # Add space between keyword and openin +g paren --opening-brace-on-new-line # Opening brace always on new line --vertical-tightness=0 # Always break line after { --vertical-tightness-closing=0 # Always break line befor } --blanks-before-comments # Blank line before comments --blanks-before-subs # Blank line before subs

But when I omit the maximum line length, undesirable things like this happen:

blah( "some argument over 80 characters");

I definitely want lines longer than 80 characters.

Replies are listed 'Best First'.
Re: Using perltidy with function arguments
by zentara (Cardinal) on Aug 23, 2010 at 15:27 UTC
    I definitely want lines longer than 80 characters.

    Isn't there some option you can pass for max_line_length? Google for "PerlTidy max line length"?

    Showing " -l=n, --maximum-line-length=n" The default maximum line length is n=80 characters

    So unless you specify it, 80 is what you get.

    What exactly is the style you are trying to achieve?

    Maybe you want -l=0?

    A basic glance at the perltidy docs says:

    FORMATTING OPTIONS Basic Options -l=n, --maximum-line-length=n The default maximum line length is n=80 characters. Perltidy will +try to find line break points to keep lines below this length. Howeve +r, long quotes and side comments may cause lines to exceed this lengt +h. Setting -l=0 is equivalent to setting -l=(a large number).

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku <flash japh
Re: Using perltidy with function arguments
by TomDLux (Vicar) on Aug 23, 2010 at 16:39 UTC
    http://perltidy.sourceforge.net/stylekey.html has detailed information about the most common perltidy options, and ends with a link to the man page. It's like a wizard on a single page.

    As Occam said: Entia non sunt multiplicanda praeter necessitatem.