2012-10-03 39 views
-2

我在STDOUT上有一些內容,我希望將這些內容安排到下降表中。在perl中自動生成表格的模塊

任何人都可以建議我一個Perl模塊做處理這種要求

在此先感謝,任何小的幫助表示讚賞。

謝謝! 阿迪亞

+1

只需使用'printf'。它是內置的,簡單的,它的工作原理。 – jordanm

+1

你需要顯示你正在處理的數據類型,以及你需要的輸出 – Borodin

回答

1

Text::TableText::ASCIITable使兩個不同的輸出,後者有輪廓。我相信CPAN會有更多的懸掛。你也可以看看formats,這是Perl功能的一小部分,用於格式化報表。

+0

感謝Joel讓我解決這些模塊...... :) –

0

假設你從現有的程序中想管的標準輸出爲其他格式,你可以用printf

創建一個名爲process.pl

#/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); 
} 
一個Perl腳本,做這樣的事情

然後,將您的標準輸出管道設置爲此,並將其格式化爲屏幕:

$ yourProcessThatDoesStdout | process.pl