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

Perltidy seems to think that this code:
sub discover { return [ { 'name' => $name, 'version' => $VERSION, } ]; }
...would look better like this (I disagree):
sub discover { return [ { 'name' => $name, 'version' => $VERSION, } ]; }
It's indenting the hash keys twice, presumably because there are two opening tokens. I'm using -sot "stack opening tokens".
But surely a large benefit of stacking opening parentheses and brackets is that you don't have to indent twice?
It's saving vertical space but wasting horizontal space.

Does anyone know the setting to control this? I've looked through the docs but not found it:
http://perltidy.sourceforge.net/perltidy.html#code_indentation_control

Replies are listed 'Best First'.
Re: Perltidy indents too much when there are stacked opening tokens
by LanX (Saint) on Oct 21, 2014 at 01:07 UTC
    The current behavior is a good default, since stacked parens doesn't mean that all data is on the same depth (see discoverX ) and yes perltidy doesn't seem to have any finer control about data indentation.

    $ perltidy -st -sct -sot tsttdy.pl sub discoverX { return [ { 'name' => $name, 'version' => $VERSION, }, [ 1, 2, 3 ] ]; } sub discover1 { return { 'name' => $name, 'version' => $VERSION, }; } sub discover2 { return [ { 'name' => $name, 'version' => $VERSION, } ]; } sub discover3 { return [ [ { 'name' => $name, 'version' => $VERSION, } ] ]; }

    For what it's worth emacs has an option to calculate the indentation relative from the last statement:

    Maybe you want to propose this feature to the maintainer?

    I'm not too convinced. But YMMV ...

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)