Help for this page

Select Code to Download


  1. or download this
    use List::Util 'reduce';
    
    ...
    my $per_line = 2;
    my $on_this_line = 0;
    print reduce {$a . (++$on_this_line % $per_line ? ',' : "\n") . $b} @a
    +rr;
    
  2. or download this
    my @arr = ('A'..'L');
    my $sep = [',', "\n"];
    print reduce {$a . ($sep->[@$sep] = shift @$sep) . $b} @arr;