Data::Tabular::Dumper is a Perl module that aims to make it easy to turn tabular data into as many file formats as possible. This is useful when you need to provide data that folks will then process further. Because you don't really know what format they want to use, you can provide as many as possible, and let them choose which they want.
Tabular data means data that has 2 dimensions, like a list of lists, a hash of lists, a list of hashes or a hash of hashes.
You may also dump 3 dimentional data; in this case, each of the top-level elements are called pages and each sub-element is independent.
While it might seem desirable to give an example for each data type, this would be onerous to maintain. Please look at the tests to see what a given data object yields.
SYNOPSIS
use Data::Tabular::Dumper;
$date=strftime('%Y%m%d', localtime);
my $dumper = Data::Tabular::Dumper->open(
XML => [ "$date.xml", "data" ],
CSV => [ "$date.csv", {} ],
Excel => [ "$date.xls" ]
);
# $data is a 2-d or 3-d data structure
$data = {
'0-monday' => { hits=>30, misses=>5, GPA=>0.42 },
'1-tuesday' => { hits=>17, misses=>3, GPA=>0.17 },
};
$dumper->dump( $data );
## If you want more control :
$dumper->page_start( "My Page" );
# what each field is called
$dumper->fields([qw(uri hits bytes)]);
# now output the data
foreach my $day (@$month) {
$dumper->write($day);
}
$dumper->page_end( "My Page" );
# sane shutdown
$dumper->close();
This would produce the following XML :
< ?xml version="1.0" encoding="iso-8859-1"? >
< access >
< My_Page >
< page >
< uri >/index.html< /uri >
< hits>4000
< bytes >5123412< /bytes >
< /page >
< page >
< uri >/something/index.html< /uri >
< hits >400< /hits >
< bytes >51234< /bytes >
< /page >
< /My_Page >
< !-- more page tags here -- >
< /access >
Product's homepage
Requirements:
· Perl