Hi All,
First of all I would like to thank all for you for your efforts and time.
I have formed a hash and I am trying to for a table from the hash
contents.
which i am able to do, but I am not able to align the text inthe columns
to center. They are aligned to left which is the default.My code
$analysis_table = Text::Table->new(\'| ',"VIEW_NAME",\' | ',"UNCERTAIN +ITY_TYPE\n TNS | WNS ",\' | '); foreach my $key(keys %analysis_hash){ my $temp = "$analysis_hash{$key}->{'uncertainity_type'} | $ana +lysis_hash{$key}->{'uncertainity_type'}" ; $analysis_table->add($key,$temp) ; } my $rule = $analysis_table->rule(qw/- +/) ; my @body = $analysis_table->body; print $rule, $analysis_table->title, $rule; for (@body) { # align('center',$_); print $_ . $rule ; }
My Output
+-----------+-------------------+
|VIEW_NAME |UNCERTAINITY_TYPE |
+-----------+-------------------+
|view1 |0.1 | 0.2 |
+-----------+-------------------+
|view2 |0.3 | 0.4 |
+-----------+-------------------+
Desired output
+-----------+-------------------+
| VIEW_NAME | UNCERTAINITY_TYPE |
+-----------+-------------------+
| view1 | 0.1 | 0.2 |
+-----------+-------------------+
| view2 | 0.3 | 0.4 |
+-----------+-------------------+
every thing aligned to center. I tried using Text::Aligner but to no success.
Please help.
In reply to alignment of text in Text::Table by kramer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |