Skip Menu |

This queue is for tickets about the Text-Table CPAN distribution.

Report information
The Basics
Id: 71181
Status: rejected
Priority: 0/
Queue: Text-Table

People
Owner: Nobody in particular
Requestors: LGODDARD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.124
Fixed in: (no value)



Subject: Data Dumper Tabulate
i would be really handy to be able to dump data in a tabular form, a Data::Dumper with style. The below works for an array of HASHes, easy to extend - do you think this fits in with your module, Text::Table, or should I wrap it up and put it in its own module? Lee our @EXPORT = qw( Tabulate ); sub Tabulate { my $rows = shift; my $tb; my @headers; foreach my $i ( @$rows ){ my $row = $i; if (ref $row eq 'HASH'){ if (not @headers){ @headers = sort keys %$row; $tb = Text::Table->new(@headers); } $row = [ @{$row}{@headers} ]; } $tb->load( $row ); } return $tb; }
Hi Lee, On Fri Sep 23 04:29:55 2011, LGODDARD wrote: Show quoted text
> i would be really handy to be able to dump data in a tabular form, a > Data::Dumper with style. > > The below works for an array of HASHes, easy to extend - do you think > this fits in with your module, Text::Table, or should I wrap it up and > put it in its own module? >
Since this can be implemented above Text-Table without modifying its internals, I feel that it belongs in a layer above it, in its own module. So please do that instead of adding the Data::Dumper-like functionality to Text-Table which will be out-of-scope for it. Regards, -- Shlomi Fish Show quoted text
> Lee > > our @EXPORT = qw( Tabulate ); > > sub Tabulate { > my $rows = shift; > my $tb; > my @headers; > foreach my $i ( @$rows ){ > my $row = $i; > if (ref $row eq 'HASH'){ > if (not @headers){ > @headers = sort keys %$row; > $tb = Text::Table->new(@headers); > } > $row = [ @{$row}{@headers} ]; > } > $tb->load( $row ); > } > return $tb; > }