AnyData is a Perl module that allows easy access to data in many formats.
SYNOPSIS
$table = adTie( 'CSV','my_db.csv','o', # create a table
{col_names=>'name,country,sex'}
);
$table->{Sue} = {country=>'de',sex=>'f'}; # insert a row
delete $table->{Tom}; # delete a single row
$str = $table->{Sue}->{country}; # select a single value
while ( my $row = each %$table ) { # loop through table
print $row->{name} if $row->{sex} eq 'f';
}
$rows = $table->{{age=>'> 25'}} # select multiple rows
delete $table->{{country=>qr/us|mx|ca/}}; # delete multiple rows
$table->{{country=>'Nz'}}={country=>'nz'}; # update multiple rows
my $num = adRows( $table, age=>'< 25' ); # count matching rows
my @names = adNames( $table ); # get column names
my @cars = adColumn( $table, 'cars' ); # group a column
my @formats = adFormats(); # list available parsers
adExport( $table, $format, $file, $flags ); # save in specified format
print adExport( $table, $format, $flags ); # print to screen in format
print adDump($table); # dump table to screen
undef $table; # close the table
adConvert( $format1, $file1, $format2, $file2 ); # convert btwn formats
print adConvert( $format1, $file1, $format2 ); # convert to screen
The rather wacky idea behind this module and its sister module DBD::AnyData is that any data, regardless of source or format should be accessable and modifiable with the same simple set of methods. This module provides a multi-dimensional tied hash interface to data in a dozen different formats. The DBD::AnyData module adds a DBI/SQL interface for those same formats.
Both modules provide built-in protections including appropriate flocking() for all I/O and (in most cases) record-at-a-time access to files rather than slurping of entire files.
Currently supported formats include general format flatfiles (CSV, Fixed Length, etc.), specific formats (passwd files, httpd logs, etc.), and a variety of other kinds of formats (XML, Mp3, HTML tables). The number of supported formats will continue to grow rapidly since there is an open API making it easy for any author to create additional format parsers which can be plugged in to AnyData itself and thereby be accessible by either the tiedhash or DBI/SQL interface.
The AnyData.pm module itself is pure Perl and does not depend on anything other than modules that come standard with Perl. Some formats and some advanced features require additional modules: to use the remote ftp/http features, you must have the LWP bundle installed; to use the XML format, you must have XML::Parser and XML::Twig installed; to use the HTMLtable format for reading, you must have HTML::Parser and HTML::TableExtract installed but you can use the HTMLtable for writing with just the standard CGI module. To use DBI/SQL commands, you must have DBI, DBD::AnyData, SQL::Statement and DBD::File installed.
Product's homepage
Requirements:
· Perl