我有以下代码片段:
my $obj = $class->new({
schema => $schema,
reminder => $reminder,
action => $action,
dt => $dt,
});
我的问题是,perltidy 试图将其格式化为如下内容:
my $obj = $class->new(
{ schema => $schema,
reminder => $reminder,
action => $action,
dt => $dt,
}
);
我不喜欢花括号的位置。我可以以某种方式配置 perltidy 以像第一个示例一样对其进行格式化吗?(跳过块的格式不是一个选项。我想将每个较长的 hashref 格式化为该格式,因此它更紧凑和可读)
到目前为止,我的 perltidyrc:
-l=79 # Max line width is 78 cols
-i=4 # Indent level is 4 cols
-ci=4 # Continuation indent is 4 cols
-st # Output to STDOUT
-se # Errors to STDERR
-vt=2 # Maximal vertical tightness
-cti=0 # No extra indentation for closing brackets
-pt=1 # Medium parenthesis tightness
-bt=1 # Medium brace tightness
-sbt=1 # Medium square bracket tightness
-bbt=1 # Medium block brace tightness
-nsfs # No space before semicolons
-nolq # Don't outdent long quoted strings
如果我删除“{}”并将参数作为列表传递,那么它会做正确的事情。但我必须通过一个 hashref。
或者您能推荐一种格式化此类代码的合理方法吗?