shlomif / Text-Table

CPAN Distribution to render text / ASCII-art / Unicode tables
https://metacpan.org/release/Text-Table
ISC License
4 stars 6 forks source link

rule( '-', '+') doesn't produce expected result #6

Closed p-alik closed 6 years ago

p-alik commented 6 years ago

Not sure I understood the documentation correctly, but I couldn't build a table with horizontal and vertical separation.

use v5.10;
use strict;
use warnings;
use Text::Table;
my $tb = Text::Table->new(qw/aaa bbb/);
$tb->rule('-', '+');
$tb->load(
  [qw/for bar/],
);
say $tb;

the code produces

aaa bbb
for bar

expected output

aaa | bbb
-----+------
for   | bar

Any help would be much appreciated

shlomif commented 6 years ago

@p-alik :

shlomif@telaviv1:~$ cat f.pl
use v5.10;
use strict;
use warnings;
use Text::Table;
my $tb = Text::Table->new(qw/aaa bbb/);
print $tb->title;
print $tb->rule('-', '+');
$tb->load(
  [qw/for bar/],
);
print $tb->body(0);
shlomif@telaviv1:~$ perl f.pl
aaa bbb
-------
for bar
shlomif@telaviv1:~$ 

hope it helps

p-alik commented 6 years ago

thank you, @shlomif. It helps indeed!

tcdaly commented 5 years ago

@p-alik 's solution doesn't completely generate the desired output, as it lacks the central '+' character and the | characters between the items of data.