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

Hi Monks,

I'm trying to figure out how to prevent perltidy from splitting lines on certain keywords I may introduce, such as "has" (Moose) etc.

I'd like to avoid perltidy from breaking lines such as:

has arg => qw(is rw isa ArrayRef), default => sub { [] }; # untidy

Into this:

has arg => qw(is rw isa ArrayRef), default => sub { [] }; # nooooooo

I'd just prefer it like this:

has arg => qw(is rw isa ArrayRef), default => sub { [] }; # much better, although I don't mind the indentation # the crucial thing is the "has arg" part

Replies are listed 'Best First'.
Re: Prevent line split for keywords in perltidy
by beech (Parson) on Nov 09, 2018 at 03:34 UTC

    Hi

    Try -boc, --break-at-old-comma-breakpoints

    $ cat 2 has arg => qw(is rw isa ArrayRef), arg => qw(is rw isa ArrayRef), defa +ult => sub { [] }; $ perltidy < 2 has arg => qw(is rw isa ArrayRef), arg => qw(is rw isa ArrayRef), default => sub { [] }; $ perltidy -boc < 2 has arg => qw(is rw isa ArrayRef), arg => qw(is rw isa ArrayRef), default => sub { [] };