是否有打印象`LS -C`列表的模块?(Is there a module that prints

2019-10-20 11:44发布

是否有一个打印(或帮我打印),它的元素是在一个字符串(标量)列表的模块ls -C时尚?

类似下面的假想方案:

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);

然后输出应该是这样的

 abc  jklmnop  uv
 def  q        wxy
 ghi  rst      z

Answer 1:

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

这是从例如demo_columns,看到在更多的例子https://metacpan.org/source/DCONWAY/Perl6-Form-0.04/demo



文章来源: Is there a module that prints a list like `ls -C`?
标签: arrays perl cpan