Questions tagged [perl-tidy]

Perl::Tidy parses and beautifies Perl source code.

perltidy : a perl script indenter and reformatter

Wikipedia

42 questions
4
votes
4 answers

Which is the closest Python equivalent to Perl::Tidy?

Coming from Perl I've been used to hitting C-c t to reformat my code according to pre-defined Perl::Tidy rules. Now, with Python I'm astonished to learn that there is nothing that even remotely resembles the power of Perl::Tidy. PythonTidy 1.20…
Nikolai Prokoschenko
  • 8,465
  • 11
  • 58
  • 97
3
votes
1 answer

How do I format qw lists using perltidy?

Assuming a Perl script such: my @a = ( 1, 2, 3 ) ; my @b = qw( foo bar baz ) ; executing perltidy with options: perltidy -nopro -ci=4 -boc -sts, I get a different closing parens alignment between the array and the qw…
Hannibal
  • 445
  • 4
  • 13
3
votes
1 answer

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…
srchulo
  • 5,143
  • 4
  • 43
  • 72
2
votes
0 answers

How can I set perltidy formating to break lines on chained methods

What setting in .perltidyrc will make that chained methods will apear in new line? Got: $t->post_ok("/foo")->status_is(200)->json_is('/data',"bar"); Expected: $t->post_ok("/foo") ->status_is(200) ->json_is('/data',"bar");
2
votes
2 answers

How can I do an in-place update of a file with perltidy?

If I want to an in-place update of a file with perltidy, how can I do it? Let's say I want to run perl-tidy on foo.pl but I want to the changes to be in foo.pl
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
2
votes
2 answers

tiding subversion Perl repo with PerlTidy?

I would like to clean up an existing subversion repository containing badly formatted Perl code. Since I am not sure if some comparisons with fairly old code will be necessary, ideally I would like to have the same formatting for all revisions. On…
darked89
  • 332
  • 1
  • 2
  • 17
2
votes
1 answer

Perltidy: an option to keep sub($args){} as a single line?

$fs->traverse('/foo')->filter(sub ($name, $dir) { $name !~ /^\./; }); $fs->traverse('/foo')->filter(sub { $_[0] !~ /^\./; }); Is there any option to keep the first line as is? Because with -pbp perltidy breaks it into 5 lines because of a…
alexbyk
  • 171
  • 2
  • 6
2
votes
2 answers

How can I set the encoding of shell-command-on-region output?

I have a small elisp script which applies Perl::Tidy on region or whole file. For reference, here's the script (borrowed from EmacsWiki): (defun perltidy-command(start end) "The perltidy command we pass markers to." (shell-command-on-region start …
Nikolai Prokoschenko
  • 8,465
  • 11
  • 58
  • 97
2
votes
1 answer

How to remove leading comment whitespace in Perl::Tidy?

I'm just configuring Perl::Tidy to match my preference. I have only one issue left which I can't find a fix. Sample script: #!/usr/bin/perl # | | | | | < "|" indicates first five "tabs" (1 tab 4 spaces). use strict; # Enable strict…
burnersk
  • 3,320
  • 4
  • 33
  • 56
2
votes
1 answer

How to sort hash entries by keys when formatting Perl source code?

Looking at perltidy I don't see such an option. Is there any tool which does this?
Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
1
vote
2 answers

Can I use perltidy's HTML formatter in my automated Perl build?

I'm using Module::Build to perform build, test, testpod, html, & install actions on my Perl module that I'm developing. The HTML files that are generated are okay, but I'd be much happier if I could somehow configure Module::Build to use the…
Kurt W. Leucht
  • 4,725
  • 8
  • 33
  • 45
1
vote
0 answers

Perltidy Unalign assignment operators (= and =>)

I have code that was previous formatted by perltidy. It has assignment operators aligned. How can I get perltidy to unalign the assignment operators. I've been all over the manual, trying and experimenting. Here's my current argument list: -i=2 -nt…
mike_haney
  • 545
  • 1
  • 8
  • 18
1
vote
1 answer

Consistent indentation of modules with Perl::Tidy

I am using Perl::Tidy and Perl::Critic while testing my software on several platforms (different Linux distributions and macOS). I now get different formatting from Perl::Tidy on Linux and macOS which makes Perl::Critic fail because the code is not…
Matteo
  • 14,696
  • 9
  • 68
  • 106
1
vote
1 answer

Can perltidy remove all leading whitespaces before performing indent rules?

Suppose I have some Perl code that looks like this use Data::Dump q[pp]; sub something{ return 2 + 2; } I want it to be formatted by perltidy as use Data::Dump q[pp]; sub something{ return 2 + 2; } That is, all leading…
sail0r
  • 445
  • 1
  • 5
  • 18
1
vote
0 answers

How to or should we sort "use Our::Class qw(may_be some_imports);" statements with Perl::Tidy (or not)?

We would like to sort use statements alphabetically in the beginning of our classes automatically via perltidy or maybe other tool if available. We already use Test::PerlTidy to test if the code is formatted before committing. I found that…
Беров
  • 1,383
  • 10
  • 22