in reply to Re^2: Adding items to arrays: best approach?
in thread Adding items to arrays: best approach?

This is indeed a purely stylistic concern. Personally, when a line needs to be split around a binary operator I would split after the operator as I think this reinforces the point that the statement isn't finished once the end of the line has been reached. I do this in any language, not just Perl. It was probably taught to me decades ago as a minor technique in aiding clarity and has stayed with me ever since.

With postfix control operators (if, unless, for etc.) it's the other way round as they are more tightly bound to the subsequent clauses (again, subjective). So I might write:

print 'Very looooooooooooooooooooooooooooooooooooooooooooooooooooooooo +ooooong non-interpolated string costing $many ', "and another clause from prog $0\n"; # but die 'Loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo +ooooooong exception message' if $OMG_ZOMBIES > $max_zombies_allowable;

Replies are listed 'Best First'.
Re^4: Adding items to arrays: best approach?
by jcb (Parson) on May 29, 2020 at 00:09 UTC

    Interestingly, the GNU convention is "When you split an expression into multiple lines, split it before an operator, not after one." but GNU style apparently does not treat commas as operators — those are still left at the end of a line.

    if (($foo && $bar && ...) || ($baz && $quux && ...)) { ... } # but function_call_with_many_lengthy_args (very_long_arg1, very_long_arg2, and_on_and_on_and_on);

    GNU style is specifically for C, but Perl syntax is reasonably similar. I suppose the point is that this really is a matter of style, except in Awk, where if I remember correctly, an operator at the end of a line also implies line continuation; the GNU convention requires backslash-newline in Awk.