Subject: | multirow pushing not working? |
Date: | Sun, 14 Jun 2009 11:14:00 +0200 |
To: | bug-Text-ASCIITable [...] rt.cpan.org |
From: | Salvatore Bonaccorso <salvatore.bonaccorso [...] gmail.com> |
Hi Håkon Nessjøen
In Debian BTS we have a bugreport regarding the multirow pushing not
working [1].
[1] Bug #402906
Indeed the following example does not work if I pass an 4x3 array:
----------------------------------------------------------------------
#!/usr/bin/perl
use Text::ASCIITable;
$t = Text::ASCIITable->new();
$t->setCols('one','two','three');
$t->addRow([
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ],
[ 0, 0, 0 ]
]);
print $t->draw();
----------------------------------------------------------------------
It produces the following output:
Received too many columns at ./ansi-example.pl line 5
.-------------------.
| one | two | three |
+-----+-----+-------+
'-----+-----+-------'
Removing the [0, 0, 0] indeed gives:
.-------------------.
| one | two | three |
+-----+-----+-------+
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |
'-----+-----+-------'
The Bugreporter notices that the problem should:
The problem is that the check for the right number of
columns in addRow() checks the first dimension of the passed array,
which is correct if you pass a single row but incorrect if you pass
an array of rows. Therefore, this only happens to work if you pass
less rows than columns.
Could you please have a look into it?
Many thanks for developing this nice Perl module,
Kind regards
Salvatore
Message body not shown because it is not plain text.