是否有打印像`LS -C`列表的模块? [英] Is there a module that prints a list like `ls -C`?

查看:102
本文介绍了是否有打印像`LS -C`列表的模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

类似以下假想方案:

 使用严格的;使用警告;使用未知::模块;我的$ LS =新未知::模块(柱=→3);$ LS  - > print_ls_C QW(ABC DEF GHI jklmnop q RST UV WXY Z);

输出应该再是这样

  ABC jklmnop UV
 高清q WXY
 首先GHIž


解决方案

 使用Perl6 ::表;
我的$ COLS = ||转变3;
我@list = QW(ABC DEF GHI jklmnop q RST UV WXY Z);
打印表格Q / {:[{*} [:} / X $ COLS,(\\ @list)×$ COLS ;;;
__结束__
ABC jklmnop UV
高清q WXY
首先GHIž

这是从例子demo_columns,请参阅 HTTPS更多的例子:// metacpan。组织/来源/ DCONWAY / Perl6外形0.04 /演示

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

解决方案

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

这篇关于是否有打印像`LS -C`列表的模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆