Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

how you will print his kind of data in table format using text::table
NAME CLASS SUBJECT EXAM Marks + AGGREGATE ---------------------------------------------------------------------- +--------------- ABC 1st year Maths Half-yearly 50 + Full-Yearly 49 + 49.5 Science Quarterly 50 Half-Yearly 48 Full-Yearly 49 + 49 English Quarterly 50 Half-Yearly 50 Full-Yearly 50 + 50 Computer Quarterly 50 Half-Yearly 50 Full-Yearly 50 + 50

Replies are listed 'Best First'.
Re: To display hash oh hash in tabular format using Text::Table
by toolic (Bishop) on Jun 20, 2012 at 13:06 UTC
    Here's one way:
    use warnings; use strict; use Text::Table; my @titles = qw(NAME CLASS SUBJECT EXAM Marks AGGREGATE); my @dashes = map { '-' x length } @titles; my $dash_row = join ' ', @dashes; my $tb_ref = Text::Table->new(@titles); $tb_ref->load($dash_row); $tb_ref->load(['ABC', '1st year', qw(Maths Half-yearly 50)]); $tb_ref->load(['', '', '', qw(Full-yearly 49 49.5)]); $tb_ref->load([' ']); $tb_ref->load(['', '', qw(Science Quarterly 50)]); print "\n$tb_ref\n"; __END__ NAME CLASS SUBJECT EXAM Marks AGGREGATE ---- ----- ------- ---- ----- --------- ABC 1st year Maths Half-yearly 50 Full-yearly 49 49.5 Science Quarterly 50

    Text::Table