我的STDOUT上有一些内容,我希望将内容安排到下降表中。
任何人都可以建议我使用Perl模块来处理这种要求
在预先感谢,任何小帮助都表示赞赏。
谢谢! 阿迪亚
答案 0 :(得分:1)
Text::Table
和Text::ASCIITable
会产生两种不同的输出,后者具有轮廓。我相信CPAN还有更多的东西。您还可以查看formats,这是一个很少使用的Perl功能,用于格式化报告。
答案 1 :(得分:0)
从CPAN,您可以使用Text::Table
答案 2 :(得分:0)
假设您想要将STDOUT从现有程序传输到其他东西以进行格式化,您可以使用printf
执行此类操作创建一个名为process.pl的perl脚本
#/bin/perl
use strict;
while (<>) {
my $unformatted_input = $_;
# Assuming you want to split on spaces, adjust if it is in fixed format.
my @elements = split / +/, $unformatted_input, 4;
# Printf format string, you can adjust lengths here. This would take
# an input of items in the elements array and make each file 10 characters
# See http://perldoc.perl.org/functions/sprintf.html for options
my $format_string='%10s%10s%10s%10s';
printf($format_string,@elements);
}
然后,将STDOUT传送给它,它会将其格式化为屏幕:
$ yourProcessThatDoesStdout | process.pl