1

Is there a module that prints (or helps me printing) a list whose elements are strings (scalars) in a ls -C fashion?

Something like the following imaginary program:

use strict; use warnings;

use Unknown::Module;

my $ls = new Unknown::Module (columns => 3);

$ls -> print_ls_C qw(abc def ghi jklmnop q rst uv wxy z);

The output should then be something like

 abc  jklmnop  uv
 def  q        wxy
 ghi  rst      z
René Nyffenegger
  • 39,402
  • 33
  • 158
  • 293

1 Answers1

2
use Perl6::Form;
my $cols = shift || 3;
my @list = qw(abc def ghi jklmnop q rst uv wxy z);
print form   q/ {:[{*}[:} / x $cols, ( \@list ) x $cols ;;;
__END__
abc                      jklmnop                  uv
def                      q                        wxy
ghi                      rst                      z

This is from example demo_columns , see more examples in https://metacpan.org/source/DCONWAY/Perl6-Form-0.04/demo

optional
  • 2,061
  • 12
  • 16