Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Perltidy alignment of fat comma =>

by LanX (Bishop)
on Sep 12, 2017 at 14:46 UTC ( #1199204=perlquestion: print w/replies, xml ) Need Help??
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 (Parson) 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!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1199204]
Approved by marto
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2017-10-20 09:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (260 votes). Check out past polls.

    Notices?