Subject: | Alignment Feature request |
Date: | Sun, 18 Aug 2019 08:37:17 +0000 |
To: | "bug-Text-Table [...] rt.cpan.org" <bug-Text-Table [...] rt.cpan.org> |
From: | Stephan Hradek <stephan.hradek [...] eco.de> |
Hi!
I just started yesterday using Text::Table and was a bit puzzled as the output wasn't what I expected.
This is the smallest example I can create to illustrate my non-understanding:
my $tb= Text::Table->new( { title => 'left' }, \' | ', { title => 'right', align => 'right' });
$tb->add('<','>');
print $tb
I got
left | right
< | >
where "<" is clearly NOT right aligned (to my understanding.
When I added
$tb->add('<<','>>')
print $tb
I got:
left | right
< | >
<< | >>
which finally clarified my misunderstanding.
Headers are not included in the calculation of the alignment.
I worked around this by changing my code to include a sample having the width of the title, so something like this:
Text::Table->new(
{
title => 'left',
sample=> '----',
},
\' | ',
{
title => 'right',
sample=> '-----',
align => 'right',
},
);
Maybe it's possible to include a method/parameter to tell the table to include the headers in the width/alignment calculation?
-- Stephan
Message body not shown because it is not plain text.