Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I format qw lists using perltidy?

Tags:

perl

perl-tidy

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 list:

my @a = (
    1,
    2,
    3
) ;

my @b = qw(
    foo
    bar
    baz
    ) ; # <== misplaced parens, I want it to be at column 1

I want to get the closing parens of the qw list aligned to column 1. What am I doing wrong, or what am I missing?

UPDATE

Thanks to the suggestion of @toolic I disabled my .perltidyrc file (my bad, I missed to do it before) and searched for the rule causing the misformatting of qw lists and found that is the --space-terminal-semicolon that alters the closing parens alignment only for qw lists.

I updated the perltidy options in the above issue description. I don't really understand if it may be a bug of perltidy or not.

Anyway, the issue is now reproducible and seems that I have to choose the lesser evil between having the closing parens of the qw lists misaligned or giving up the space before the semicolon at the end of the statements :-(

like image 617
Hannibal Avatar asked Nov 17 '25 04:11

Hannibal


1 Answers

I am unable to reproduce your result. I do not have a .perltidyrc command file, which can have options that are not on your command line.

You can use the perltidy -nopro option to ignore any .perltidyrc command file, if you have one.

like image 60
toolic Avatar answered Nov 18 '25 20:11

toolic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!