in reply to how to alternate join?
Alternatively, you could use List::Util 'reduce' to roll your own version of join that does the same thing.
oruse List::Util 'reduce'; my @arr = ('A'..'L'); my $per_line = 2; my $on_this_line = 0; print reduce {$a . (++$on_this_line % $per_line ? ',' : "\n") . $b} @a +rr;
The last works, though it's possibly too clever. What if the left @$sep is evaluated before the shift?my @arr = ('A'..'L'); my $sep = [',', "\n"]; print reduce {$a . ($sep->[@$sep] = shift @$sep) . $b} @arr;
|
|---|