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

Hi

colleague asked me how to make perltidy align all fat commas in a hash.

The ternary in the following example seems to block alignment

#!/usr/bin/perl use strict; use warnings; sub test { my ( $result, $data, $date ); return { res => 1 ? 1 : 0, errtext => $result->{errtext}, info => $data, timestamp => ( $date->dmy('-') . ' ' . $date->hms ), }; }

>perltidy -pbp tidy_align.pl #!/usr/bin/perl -w use strict; use warnings; sub test { my ( $result, $data, $date ); return { res => 1 ? 1 : 0, errtext => $result->{errtext}, info => $data, timestamp => ( $date->dmy('-') . ' ' . $date->hms ), }; }

FWIW adding another entry before the ternary seems to make it work again.

Browsed thru documentation couldn't find a flag addressing this, not sure which term is used for "alignment" of values in recursive structures.

Looks like a bug for me ... ideas?

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re: Perltidy alignment of fat comma =>
by Arunbear (Prior) on Sep 13, 2017 at 10:01 UTC
    Such an option ought to be in the 'Code Indentation Control' section, but I couldn't find one. It does seem like a bug.
      Yeah most probably a bug, had the same problem with perltidy, v20160302 and the CHANGES of the CPAN distribution do not mention any related fix.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

Re: Perltidy alignment of fat comma =>
by onefloid (Initiate) on Oct 03, 2018 at 06:23 UTC
    The bug is fixed in version 2018 02 19. Now it works.
      good to know, thanks :)

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice