AnyData

 view release on metacpan or  search on metacpan

lib/AnyData.pm  view on Meta::CPAN

   #
   print adExport($table,'HTMLtable');

   # export the table to an array reference
   #
   my $aryref = adExport($table,'ARRAY');

 See section below "Using strings and arrays" for details.

=head2 adNames()

 my $table = adTie(...);
 my @column_names = adNames($table);

This method returns an array of the column names for the specified table.

=head2 adRows()

 my $table = adTie(...);
 adRows( $table, %search_hash );

This method takes an AnyData tied hash created with adTie() and
counts the rows in the table that match the search hash.

For example, this snippet returns a count of the rows in the
file that contain the specified page in the request column

  my $hits = adTie( 'Weblog', 'access.log');
  print adRows( $hits , request => 'mypage.html' );

The search hash may contain multiple search criteria, see the
section on multiple row operations below.

If the search_hash is omitted, it returns a count of all rows.

=head2 adColumn()

 my @col_vals = adColumn( $table, $column_name, $distinct_flag );

This method returns an array of values taken from the specified column.
If there is a distinct_flag parameter, duplicates will be eliminated
from the list.

For example, this snippet returns a unique list of the values in
the 'player' column of the table.

  my $game = adTie( 'Pipe','games.db' );
  my @players  = adColumn( $game, 'player', 1 );

=head2 adDump()

  my $table = adTie(...);
  print adDump($table);

This method prints the raw data in the table.  Column names are printed inside angle brackets and separated by colons on the first line, then each row is printed as a list of values inside square brackets.

=head2 adFormats()

  print "$_\n for adFormats();

This method shows the available format parsers, e.g. 'CSV', 'XML', etc.  It looks in your @INC for the .../AnyData/Format directory and prints the names of format parsing files there.  If the parser requires further modules (e.g. XML requires XML::Pa...

=head1 FURTHER DETAILS

=head2 Column Names

Column names may be assigned in three ways:

 * pre  -- The format parser preassigns column
           names (e.g. Passwd files automatically have
           columns named 'username', 'homedir', 'GID', etc.).

 * user -- The user specifies the column names as a comma
           separated string associated with the key 'cols':

           my $table = adTie( $format,
                              $file,
                              $mode,
                              {cols=>'name,age,gender'}
                            );

 * auto -- If there is no preassigned list of column names
           and none defined by the user, the first line of
           the file is treated as a list of column names;
           the line is parsed according to the specific
           format (e.g. CSV column names are a comma-separated
           list, Tab column names are a tab separated list);

When creating a new file in a format that does not preassign
column names, the user *must* manually assign them as shown above.

Some formats have special rules for assigning column names (XML,Fixed,HTMLtable), see the sections below on those formats.

=head2 Key Columns

The AnyData modules support tables that have a single key column that
uniquely identifies each row as well as tables that do not have such
keys.  For tables where there is a unique key, that key may be assigned
in three ways:

 * pre --  The format parser automatically preassigns the
           key column name e.g. Passwd files automatically
           have 'username' as the key column.

 * user -- The user specifies the key column name:

           my $table = adTie( $format,
                              $file,
                              $mode,
                              {key=>'country'}
                            );

 * auto    If there is no preassigned key column and the user
           does not define one, the first column becomes the
           default key column

=head2 Format Specific Details

 For full details, see the documentation for AnyData::Format::Foo
 where Foo is any of the formats listed in the adFormats() command
 e.g. 'CSV', 'XML', etc.



( run in 2.169 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )