Subject: | PT indents closing brace of map expr as line continuation. |
I have an expression like this:
coerce Q2RawStatGroupArray, from ArrayRef [Q2StatGroup], via {
[
map {
my $g = $_->as_hash;
$g->{stats} = [
map { scalar $_->as_array } @{ $g->{stats} }
];
$g;
}
@$_;
]
};
perltidy -npro --indent-columns=2 changes it to this:
coerce Q2RawStatGroupArray, from ArrayRef [Q2StatGroup], via {
[
map {
my $g = $_->as_hash;
$g->{stats} = [ map { scalar $_->as_array } @{ $g->{stats} } ];
$g;
} @$_
];
};
which is extremely close to what I want, which is this:
coerce Q2RawStatGroupArray, from ArrayRef [Q2StatGroup], via {
[
map {
my $g = $_->as_hash;
$g->{stats} = [ map { scalar $_->as_array } @{ $g->{stats} } ];
$g;
} @$_
];
};
Some playing around has shown me that the "} @$_" line is being indented according to the
continuation indentation. I've poked around the perltidy source a little, but have no clue
how I might patch it to get the desired behavior.
I do see that PT handles simple "stacked" map/sort/grep expressions as expected, eg:
my @foo =
map { ... }
sort { ... }
map { ... } @foo;
And when done within anonymous array brackets it's fine...
my $foo = [
map { ... }
sort { ... }
map { ... } @foo
];
So I'm not sure if this is a bug, or expected behavior (and thus I would need a new config
option to get what I want)
Anyhow, thank you for PerlTidy!