Search code examples
perlperl-tidy

Perltidy always prints to standard out


My Perltidy always prints to standard out instead of the default test.pl.tdy:

perltidy test.pl

And here is my .perltidyrc:

-pbp # Start with Perl Best Practices
-w
-l=100   # 100 characters per line
-ce # 'cuddled' elses. elses appear on the same line as last brace
-pt=2 # no parentheses spacing
-pt=2    # High parenthesis tightness
-bt=2    # High brace tightness
-sbt=2   # High square bracket tightness
-bar # opening braces right
-nsbl # open subroutine brace on right
-bbvt=1 # Block Brace Vertical Tightness
-sot # stack opening tokens
-sct # stack closing tokens
-nsfs # no For Loop Semicolon Spaces
-nolq # don't outdent long strings

Even if I do:

perltidy -b test.pl

It will still print to standard out and not go to test.pl.bak. The only way I can get it to go to a different file is by doing:

perltidy test.pl > test.pl.tdy

Is there something in my .perltidyrc that could be causing this? I can't seem to find anything to explain it.


Solution

  • The documentation says in Styles section

    -pbp, --perl-best-practices
    -pbp is an abbreviation for the parameters in the book Perl Best Practices by Damian Conway:

    -l=78 -i=4 -ci=4 -st -se -vt=2 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nsfs -nolq
    -wbb="% + - * / x != == >= <= =~ !~ < > | & =
          **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x="
    

    Please note that this parameter set includes -st and -se flags, which make perltidy act as a filter on one file only. These can be overridden by placing -nst and/or -nse after the -pbp parameter.

    (my emphasis)   The relevant flags are described in I/O control section.

    I don't know why -pbp includes the flags to print to standard streams, which imply that there must be only one input file, but there may be a reason; so it may be a good idea to inspect in detail what all those flags under it do.

    I find that -nst (--nostandard-ouput) works even right after the -pbp, on the same line.