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 | |
by LanX (Saint) on Sep 13, 2017 at 14:01 UTC | |
Re: Perltidy alignment of fat comma =>
by onefloid (Initiate) on Oct 03, 2018 at 06:23 UTC | |
by LanX (Saint) on Oct 03, 2018 at 11:23 UTC |
Back to
Seekers of Perl Wisdom