[libanydata-perl] 01/06: Imported Upstream version 0.12

Lucas Kanashiro kanashiro-guest at moszumanska.debian.org
Thu Jul 23 03:45:51 UTC 2015


This is an automated email from the git hooks/post-receive script.

kanashiro-guest pushed a commit to branch master
in repository libanydata-perl.

commit 2e7448d3a879370967d2b8d1e615f66ea185d1d2
Author: Lucas Kanashiro <kanashiro.duarte at gmail.com>
Date:   Thu Jul 23 00:32:36 2015 -0300

    Imported Upstream version 0.12
---
 Changes                                      |   35 +-
 MANIFEST                                     |   52 +-
 MANIFEST.SKIP                                |    6 +
 META.json                                    |   53 +-
 META.yml                                     |   28 +-
 Makefile.PL                                  |  154 +-
 lib/AnyData.pm                               | 2902 +++++++++++++-------------
 {AnyData => lib/AnyData}/Format/Base.pm      |    0
 {AnyData => lib/AnyData}/Format/CSV.pm       |    2 +-
 {AnyData => lib/AnyData}/Format/FileSys.pm   |    0
 {AnyData => lib/AnyData}/Format/Fixed.pm     |    2 +-
 {AnyData => lib/AnyData}/Format/HTMLtable.pm |    2 +-
 {AnyData => lib/AnyData}/Format/Ini.pm       |    2 +-
 {AnyData => lib/AnyData}/Format/Mp3.pm       |    2 +-
 {AnyData => lib/AnyData}/Format/Paragraph.pm |    2 +-
 {AnyData => lib/AnyData}/Format/Passwd.pm    |    2 +-
 {AnyData => lib/AnyData}/Format/Pipe.pm      |    2 +-
 {AnyData => lib/AnyData}/Format/Tab.pm       |    2 +-
 {AnyData => lib/AnyData}/Format/Text.pm      |    0
 {AnyData => lib/AnyData}/Format/Weblog.pm    |    2 +-
 {AnyData => lib/AnyData}/Format/XML.pm       |    2 +-
 {AnyData => lib/AnyData}/Storage/File.pm     |    0
 {AnyData => lib/AnyData}/Storage/File.pod    |    0
 {AnyData => lib/AnyData}/Storage/FileSys.pm  |    0
 {AnyData => lib/AnyData}/Storage/PassThru.pm |    2 +-
 {AnyData => lib/AnyData}/Storage/RAM.pm      |    2 +-
 {AnyData => lib/AnyData}/Storage/TiedHash.pm |    0
 t/htmltable.out                              |    1 -
 t/xml.out                                    |    0
 xt/distribution.t                            |   17 -
 xt/kwalitee.t                                |    6 -
 xt/manifest.t                                |    9 -
 xt/pod-coverage.t                            |   22 -
 xt/pod-snippets.t                            |   12 -
 xt/pod.t                                     |   12 -
 xt/spelling.t                                |   48 -
 36 files changed, 1683 insertions(+), 1700 deletions(-)

diff --git a/Changes b/Changes
index 5f50a15..c110a2c 100644
--- a/Changes
+++ b/Changes
@@ -2,7 +2,16 @@ AnyData - easy access to data in many formats
 
 Revision history for Perl extension AnyData.
 
-version 0.11, released  Aug 2012
+0.12	2015-01-28
+
+ * fix various packaging issues (RT#101768, RT#95908, RT#99763, RT#82862)
+ * add missing prereq on CGI (RT#99916)
+ * officially marked as deprecated
+ * tidy up distribution
+ * reformat Changes according to rough spec
+ * fix some meta-data #toolchain pointed out
+
+0.11	2012-12-14
 
  * new maintainer Sven Dowideit
  * use Test::More
@@ -14,28 +23,29 @@ version 0.11, released  Aug 2012
  * weblog request and referer regexs were too greedy, and the referer and client regex's where in the wrong order (RT#34063) and (RT#72334) Wes Brown <wes [...] smellycat.com> and pawal [...] blipp.com
  * adDump writes out fields containing 0 as empty strings (RT#28006) xcaron [...] gmail.com
  * A bug in AnyData::Format::Weblog, SQL excuting result is not correct (RT#56962) youngyik at gmail.com
+ * 
 
-version 0.10, released 19 April 2004
+0.10	2004-04-19
 
  * really fixed adConvert, thanks for bug reports - Dan Wright, Scott Godin
 
-version 0.09, released 18 April 2004
+0.09	2004-04-18
 
  * fixed adConvert - many thanks to Dan Wright for a patch
 
-version 0.08, released 25 October 2003
+0.08	2003-10-25
  
  * Storage/RAM.pm : added version number
 
-version 0.07, released 25 October 2003
+0.07	2003-10-25
  
  * Storage/PassThru.pm : added version number (thanks Randal Schwartz)
 
-version 0.06, released 25 October 2003
+0.06	2003-10-25
 
  * test.pl : omitted XML & HTMLtable tests
 
-version 0.05, released 17 July, 2001
+0.05	2001-07-17
 
  There are major changes in the way the tied hash interface
  does deletions and exporting and in the XML and Weblog format
@@ -86,21 +96,18 @@ version 0.05, released 17 July, 2001
  * added version numbers to all of the submodules and standardized
    the docs
 
-Version 0.04, 26th June, 2001
+0.04	2001-06-26
 
  * Beta release
 
-Version 0.03, 17th April, 2001
+0.03	2001-03-17
 
  * second Alpha release
 
-Version 0.02, 4th February, 2001
+0.02	2001-02-04
 
  * first Alpha release
 
-Version 0.01, 17th January, 2001
+0.01	2001-01-17
 
  * pre Alpha release
-
-
-
diff --git a/MANIFEST b/MANIFEST
index 40e969a..254bf95 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,29 +1,28 @@
-AnyData/Format/Base.pm
-AnyData/Format/CSV.pm
-AnyData/Format/FileSys.pm
-AnyData/Format/Fixed.pm
-AnyData/Format/HTMLtable.pm
-AnyData/Format/Ini.pm
-AnyData/Format/Mp3.pm
-AnyData/Format/Paragraph.pm
-AnyData/Format/Passwd.pm
-AnyData/Format/Pipe.pm
-AnyData/Format/Tab.pm
-AnyData/Format/Text.pm
-AnyData/Format/Weblog.pm
-AnyData/Format/XML.pm
-AnyData/Storage/File.pm
-AnyData/Storage/File.pod
-AnyData/Storage/FileSys.pm
-AnyData/Storage/PassThru.pm
-AnyData/Storage/RAM.pm
-AnyData/Storage/TiedHash.pm
 Changes
-Debian_CPANTS.txt
 lib/AnyData.pm
+lib/AnyData/Format/Base.pm
+lib/AnyData/Format/CSV.pm
+lib/AnyData/Format/FileSys.pm
+lib/AnyData/Format/Fixed.pm
+lib/AnyData/Format/HTMLtable.pm
+lib/AnyData/Format/Ini.pm
+lib/AnyData/Format/Mp3.pm
+lib/AnyData/Format/Paragraph.pm
+lib/AnyData/Format/Passwd.pm
+lib/AnyData/Format/Pipe.pm
+lib/AnyData/Format/Tab.pm
+lib/AnyData/Format/Text.pm
+lib/AnyData/Format/Weblog.pm
+lib/AnyData/Format/XML.pm
+lib/AnyData/Storage/File.pm
+lib/AnyData/Storage/File.pod
+lib/AnyData/Storage/FileSys.pm
+lib/AnyData/Storage/PassThru.pm
+lib/AnyData/Storage/RAM.pm
+lib/AnyData/Storage/TiedHash.pm
 LICENSE
 Makefile.PL
-MANIFEST
+MANIFEST			This list of files
 MANIFEST.SKIP
 README
 t/56962.log
@@ -31,19 +30,10 @@ t/56962.t
 t/api.t
 t/fixed.t
 t/fixed.tbl
-t/htmltable.out
 t/htmltable.t
 t/test.t
 t/weblog.t
 t/weblog.tbl
-t/xml.out
 t/xml.t
-xt/distribution.t
-xt/kwalitee.t
-xt/manifest.t
-xt/pod-coverage.t
-xt/pod-snippets.t
-xt/pod.t
-xt/spelling.t
 META.yml                                 Module YAML meta-data (added by MakeMaker)
 META.json                                Module JSON meta-data (added by MakeMaker)
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP
index a77993e..7f2a911 100644
--- a/MANIFEST.SKIP
+++ b/MANIFEST.SKIP
@@ -1,3 +1,4 @@
+#!include_default
 \B\.svn\b
 \.[Bb][Aa][Kk]$
 \.orig$
@@ -27,3 +28,8 @@ _Inline/.*
 ~$
 ^MYMETA.*$
 AnyData-.*
+/t/htmltable.out
+\.[co]
+\.bs
+\bxt\b/
+.travis.yml
diff --git a/META.json b/META.json
index 960fb4c..a34812f 100644
--- a/META.json
+++ b/META.json
@@ -1,11 +1,11 @@
 {
-   "abstract" : "easy access to data in many formats
",
+   "abstract" : "(DEPRECATED) easy access to data in many formats",
    "author" : [
       "Jeff Zucker (jeff at vpservices.com)",
       "Sven Dowideit (SvenDowideit at fosiki.com)"
    ],
-   "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.120921",
+   "dynamic_config" : 0,
+   "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240",
    "license" : [
       "perl_5"
    ],
@@ -22,26 +22,55 @@
    },
    "prereqs" : {
       "build" : {
+         "requires" : {}
+      },
+      "configure" : {
          "requires" : {
-            "Test::More" : "0.9",
-            "Test::Output" : "0.01"
+            "ExtUtils::MakeMaker" : "0"
          }
       },
-      "configure" : {
+      "develop" : {
          "requires" : {
-            "ExtUtils::MakeMaker" : "6.30"
+            "Module::CPANTS::Analyse" : "0.96",
+            "Test::CPAN::Changes" : "0",
+            "Test::CheckManifest" : "0",
+            "Test::Kwalitee" : "0",
+            "Test::Pod" : "0",
+            "Test::Pod::Coverage" : "0",
+            "Test::Pod::Spelling::CommonMistakes" : "0",
+            "Test::Spelling" : "0"
          }
       },
       "runtime" : {
-         "requires" : {}
+         "requires" : {
+            "CGI" : "0"
+         }
+      },
+      "test" : {
+         "requires" : {
+            "Test::More" : "0",
+            "Test::Output" : "0"
+         }
       }
    },
    "release_status" : "stable",
    "resources" : {
-      "homepage" : "http://github.com/SvenDowideit/Data-Foswiki",
+      "bugtracker" : {
+         "mailto" : "bug-AnyData at rt.cpan.org",
+         "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=AnyData"
+      },
+      "homepage" : "https://metacpan.org/release/AnyData",
+      "license" : [
+         "http://dev.perl.org/licenses/"
+      ],
       "repository" : {
-         "url" : "git://github.com/SvenDowideit/Data-Foswiki.git"
-      }
+         "type" : "git",
+         "url" : "https://github.com/perl5-dbi/AnyData.git",
+         "web" : "https://github.com/perl5-dbi/AnyData"
+      },
+      "x_IRC" : "irc://irc.perl.org/#dbi",
+      "x_MailingList" : "mailto:dbi-dev at perl.org'",
+      "x_deprecated" : 1
    },
-   "version" : "0.11"
+   "version" : "0.12"
 }
diff --git a/META.yml b/META.yml
index b07191f..2455306 100644
--- a/META.yml
+++ b/META.yml
@@ -1,26 +1,32 @@
 ---
-abstract: "easy access to data in many formats
"
+abstract: '(DEPRECATED) easy access to data in many formats'
 author:
   - 'Jeff Zucker (jeff at vpservices.com)'
   - 'Sven Dowideit (SvenDowideit at fosiki.com)'
 build_requires:
-  Test::More: 0.9
-  Test::Output: 0.01
+  Test::More: '0'
+  Test::Output: '0'
 configure_requires:
-  ExtUtils::MakeMaker: 6.30
-dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.120921'
+  ExtUtils::MakeMaker: '0'
+dynamic_config: 0
+generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
-  version: 1.4
+  version: '1.4'
 name: AnyData
 no_index:
   directory:
     - t
     - inc
-requires: {}
+requires:
+  CGI: '0'
 resources:
-  homepage: http://github.com/SvenDowideit/Data-Foswiki
-  repository: git://github.com/SvenDowideit/Data-Foswiki.git
-version: 0.11
+  Deprecated: 1
+  IRC: irc://irc.perl.org/#dbi
+  MailingList: "mailto:dbi-dev at perl.org'"
+  bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=AnyData
+  homepage: https://metacpan.org/release/AnyData
+  license: http://dev.perl.org/licenses/
+  repository: https://github.com/perl5-dbi/AnyData.git
+version: '0.12'
diff --git a/Makefile.PL b/Makefile.PL
index f571759..e7f5f12 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -1,47 +1,119 @@
 # -*- perl -*-
-
-require 5.006;
 use strict;
-require ExtUtils::MakeMaker;
-ExtUtils::MakeMaker::WriteMakefile(
-    (
-        'NAME'          => 'AnyData',
-        'VERSION_FROM'  => 'lib/AnyData.pm',
-        'ABSTRACT_FROM' => 'lib/AnyData.pm',
-        'LICENSE'       => "perl",
-        'dist'          => {
-            'SUFFIX'       => ".gz",
-            'DIST_DEFAULT' => 'all tardist',
-            'COMPRESS'     => "gzip -9vf"
-        },
-        'CONFIGURE_REQUIRES' => { "ExtUtils::MakeMaker" => "6.30" },
-        'BUILD_REQUIRES'     => {
-            'Test::Output'                        => '0.01',
-            'Test::More'                          => '0.9',
+
+use 5.008001;
+
+use ExtUtils::MakeMaker;
+
+my %RUN_DEPS = ( 'CGI' => '0' );
+my %CONFIGURE_DEPS = (
+    'ExtUtils::MakeMaker' => 0,
+);
+my %BUILD_DEPS = ();
+
+my %TEST_DEPS = (
+    'Test::Output' => '0',
+    'Test::More'   => '0',
+);
+my @AUTHORS = ( 'Jeff Zucker (jeff at vpservices.com)', 'Sven Dowideit (SvenDowideit at fosiki.com)', );
+
+WriteMakefile1(
+    MIN_PERL_VERSION => '5.008001',
+    META_ADD         => {
+        'meta-spec'    => { version => 2 },
+        dynamic_config => 0,
+        resources      => {
+            homepage   => 'https://metacpan.org/release/AnyData',
+            repository => {
+                url  => 'https://github.com/perl5-dbi/AnyData.git',
+                web  => 'https://github.com/perl5-dbi/AnyData',
+                type => 'git',
+            },
+            bugtracker => {
+                web    => 'http://rt.cpan.org/Public/Dist/Display.html?Name=AnyData',
+                mailto => 'bug-AnyData at rt.cpan.org',
+            },
+            license       => 'http://dev.perl.org/licenses/',
+            x_deprecated  => 1,
+            x_IRC         => "irc://irc.perl.org/#dbi",
+            x_MailingList => "mailto:dbi-dev\@perl.org'",
         },
-        'PREREQ_PM' => {},
-        "test"      => { "TESTS" => "t/*.t" },
-        "META_ADD"  => {
-            resources => {
-                homepage   => 'http://github.com/SvenDowideit/Data-Foswiki',
-                repository => 'git://github.com/SvenDowideit/Data-Foswiki.git',
-
-                #            x_twitter => 'http://twitter.com/SvenDowideit/',
-            }
+        prereqs => {
+            develop => {
+                requires => {
+                    'Test::CPAN::Changes'                 => 0,
+                    'Test::CheckManifest'                 => 0,
+                    'Module::CPANTS::Analyse'             => '0.96',
+                    'Test::Kwalitee'                      => 0,
+                    'Test::Pod'                           => 0,
+                    'Test::Pod::Coverage'                 => 0,
+                    'Test::Pod::Spelling::CommonMistakes' => 0,
+                    'Test::Spelling'                      => 0,
+                },
+            },
+            configure => {
+                requires => {%CONFIGURE_DEPS},
+            },
+            build   => { requires => {%BUILD_DEPS} },
+            test    => { requires => {%TEST_DEPS} },
+            runtime => {
+                requires => { %RUN_DEPS, },
+            },
         },
-        ( $ExtUtils::MakeMaker::VERSION >= 6.3002 ?
-              ( 'LICENSE' => 'perl', )
-            : () ),
-        (
-            $ExtUtils::MakeMaker::VERSION >= 5.43
-            ? (
-                'AUTHOR' => [
-                    'Jeff Zucker (jeff at vpservices.com)',
-                    'Sven Dowideit (SvenDowideit at fosiki.com)',
-                ]
-              )
-            : ()
-        ),
-    )
+    },
+    NAME               => 'AnyData',
+    VERSION_FROM       => 'lib/AnyData.pm',
+    ABSTRACT_FROM      => 'lib/AnyData.pm',
+    LICENSE            => "perl",
+    AUTHOR             => \@AUTHORS,
+    CONFIGURE_REQUIRES => \%CONFIGURE_DEPS,
+    BUILD_REQUIRES     => \%BUILD_DEPS,
+    PREREQ_PM          => \%RUN_DEPS,
+    TEST_REQUIRES      => \%TEST_DEPS,
+    test               => { TESTS => 't/*.t xt/*.t' },
 );
 
+sub WriteMakefile1
+{    # originally written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
+    my %params       = @_;
+    my $eumm_version = $ExtUtils::MakeMaker::VERSION;
+    $eumm_version = eval $eumm_version;
+    die "EXTRA_META is deprecated" if ( exists( $params{EXTRA_META} ) );
+    die "License not specified"    if ( !exists( $params{LICENSE} ) );
+    $params{TEST_REQUIRES}
+      and $eumm_version < 6.6303
+      and $params{BUILD_REQUIRES} = { %{ $params{BUILD_REQUIRES} || {} }, %{ delete $params{TEST_REQUIRES} } };
+    #EUMM 6.5502 has problems with BUILD_REQUIRES
+    $params{BUILD_REQUIRES}
+      and $eumm_version < 6.5503
+      and $params{PREREQ_PM} = { %{ $params{PREREQ_PM} || {} }, %{ delete $params{BUILD_REQUIRES} } };
+    ref $params{AUTHOR}
+      and "ARRAY" eq ref $params{AUTHOR}
+      and $eumm_version < 6.5702
+      and $params{AUTHOR} = join( ", ", @{ $params{AUTHOR} } );
+    delete $params{CONFIGURE_REQUIRES}    if ( $eumm_version < 6.52 );
+    delete $params{MIN_PERL_VERSION}      if ( $eumm_version < 6.48 );
+    delete $params{META_MERGE}            if ( $eumm_version < 6.46 );
+    delete $params{META_ADD}{prereqs}     if ( $eumm_version < 6.58 );
+    delete $params{META_ADD}{'meta-spec'} if ( $eumm_version < 6.58 );
+    delete $params{META_ADD}              if ( $eumm_version < 6.46 );
+    delete $params{LICENSE}               if ( $eumm_version < 6.31 );
+    delete $params{AUTHOR}                if ( $] < 5.005 );
+    delete $params{ABSTRACT_FROM}         if ( $] < 5.005 );
+    delete $params{BINARY_LOCATION}       if ( $] < 5.005 );
+
+    # more or less taken from Moose' Makefile.PL
+    if ( $params{CONFLICTS} )
+    {
+        my $ok = CheckConflicts(%params);
+        exit(0) if ( $params{PREREQ_FATAL} and not $ok );
+        my $cpan_smoker = grep { $_ =~ m/(?:CR_SMOKER|CPAN_REPORTER|AUTOMATED_TESTING)/ } keys %ENV;
+        unless ( $cpan_smoker || $ENV{PERL_MM_USE_DEFAULT} )
+        {
+            sleep 4 unless ($ok);
+        }
+        delete $params{CONFLICTS};
+    }
+
+    WriteMakefile(%params);
+}
diff --git a/lib/AnyData.pm b/lib/AnyData.pm
index 910b535..682ac1a 100755
--- a/lib/AnyData.pm
+++ b/lib/AnyData.pm
@@ -1,1451 +1,1451 @@
-##################################################################
-package AnyData;
-###################################################################
-#
-#   This module is copyright (c), 2000 by Jeff Zucker
-#   All rights reserved.
-#
-###################################################################
-use strict;
-use warnings;
-require Exporter;
-use AnyData::Storage::TiedHash;
-use vars qw( @ISA @EXPORT $VERSION );
- at ISA = qw(Exporter);
- at EXPORT = qw(  adConvert adTie adRows adColumn adExport adDump adNames adFormats);
-#@EXPORT = qw(  ad_fields adTable adErr adArray);
-
-$VERSION = '0.11';
-
-sub new {
-   my $class   = shift;
-   my $format  = shift;
-   my $flags   = shift || {};
-   my $del_marker = "\0";
-   $format = 'CSV' if $format eq 'ARRAY';
-   my $parser_name = 'AnyData/Format/' . $format . '.pm';
-   eval { require $parser_name; };
-   die "Error Opening File-Parser: $@" if $@;
-   $parser_name =~ s#/#::#g;
-   $parser_name =~ s#\.pm$##g;
-    my $col_names = $flags->{col_names} || undef;
-    if ($col_names) {
-        my @cols;
-        @cols = ref $col_names eq 'ARRAY'
-          ? @$col_names
-          : split ',',$col_names;
-        $flags->{col_names} = \@cols;
-   }
-   $flags->{del_marker} = $del_marker;
-   $flags->{records}   ||= $flags->{data};
-   $flags->{field_sep} ||= $flags->{sep_char}   ||= $flags->{ad_sep_char};
-   $flags->{quote}     ||= $flags->{quote_char} ||= $flags->{ad_quote_char};
-   $flags->{escape}    ||= $flags->{escape_char}||= $flags->{ad_escape_char};
-   $flags->{record_sep}||= $flags->{eol}        ||= $flags->{ad_eol};
-   # $flags->{skip_first_row}
-   my $parser    = $parser_name->new ($flags);
-   if ($parser->{col_names} && !$col_names) {
-        my @cols;
-        @cols = ref $parser->{col_names} eq 'ARRAY'
-          ? @{$parser->{col_names}}
-          : split ',',$parser->{col_names};
-        $flags->{col_names} = \@cols;
-        $parser->{col_names} = \@cols;
-   }
-   my $storage_name = $flags->{storage}
-                   || $parser->storage_type()
-                   || 'File';
-   $storage_name = "AnyData/Storage/$storage_name.pm";
-   eval { require $storage_name; };
-   die "Error Opening Storage Module: $@" if $@;
-   $storage_name =~ s#/#::#g;
-   $storage_name =~ s#\.pm$##g;
-   my $storage   = new $storage_name({del_marker=>$del_marker,%$flags});
-   if ($storage_name =~ 'PassThru') {
-       $storage->{parser} = $parser;
-       $parser->{del_marker} = "\0";
-       $parser->{url} = $flags->{file} 
-                      if $flags->{file} and $flags->{file} =~ /http:|ftp:/;
-   }
-   my $self = {
-       storage => $storage,
-       parser  => $parser,
-   };
-   return( bless($self,$class) );
-}
-
-sub adFormats {
-    my @formats;
-    for my $dir(@INC) {
-        my $format_dir = "$dir/AnyData/Format";
-        if ( -d $format_dir ) {
-            local *D;
-            opendir(D,$format_dir);
-            @formats = grep {/\.pm$/} readdir(D);
-            last;
-        }
-    }
-    unshift @formats,'ARRAY';
-    @formats = map {s/^(.*)\.pm$/$1/;$_} @formats;
-    return @formats;
-}
-
-sub export {
-    my $self=shift;
-    my $fh   = $self->{storage}->{fh};
-    my $mode = $self->{storage}->{open_mode} || 'r';
-#    if ( $self->{parser}->{export_on_close}
-#      && $self->{storage}->{fh}
-#      && $mode ne 'r'
-#     ){
-      return $self->{parser}->export( $self->{storage}, @_ );
-#    }
-}
-sub DESTROY {
-    my $self=shift;
-#    $self->export;
-    $self->zpack;
-    #print "AD DESTROYED ";
-}
-##########################################
-# DBD STUFF
-##########################################
-# required only for DBD-AnyData
-##########################################
-sub prep_dbd_table {
-    my $self       = shift;
-    my $tname      = shift;
-    my $createMode = shift;
-    my $col_names;
-    my $col_nums;
-    my $first_row_pos;
-    if (!$createMode) {
-        $col_names     = $self->{storage}->get_col_names($self->{parser});
-        $col_nums      = $self->{storage}->set_col_nums();
-        $first_row_pos = $self->{storage}->{first_row_pos};
-    }
-    die "ERROR: No Column Names!:", $self->{storage}->{open_mode}
-     if (!$col_names || !scalar @$col_names) 
-     && 'ru' =~ $self->{storage}->{open_mode}
-     && !$createMode eq 'o';
-    my $table = {
-        NAME          => $tname,
-        DATA          => [],
-        CURRENT_ROW   => 0,
-        col_names     => $col_names,
-        col_nums      => $col_nums,
-        first_row_pos => $first_row_pos,
-        fh            => $self->{storage}->get_file_handle,
-        file          => $self->{storage}->get_file_name,
-        ad            => $self,
-    };
-    #use Data::Dumper; print Dumper $table;
-    return $table;
-}
-sub fetch_row   {
-    my $self   = shift;
-    my $requested_cols = shift || [];
-    my $rec;
-    if ( $self->{parser}->{skip_pattern} ) {
-        my $found;
-        while (!$found) {
-            $rec = $self->{storage}->file2str($self->{parser},$requested_cols);
-            last if !defined $rec;
-            next if $rec =~ $self->{parser}->{skip_pattern};
-            last;
-	}
-    }
-    else {
-        $rec = $self->{storage}->file2str($self->{parser},$requested_cols);
-    }
-    return $rec if ref $rec eq 'ARRAY';
-    return unless $rec;
-    my @fields = $self->{parser}->read_fields($rec);
-    return undef if scalar @fields == 1 and !defined $fields[0];
-    return \@fields;
-}
-sub fetch_rowNEW   {
-    my $self   = shift;
-    my $requested_cols = shift || [];
-    my $rec    = $self->{storage}->file2str($self->{parser},$requested_cols);
-    my @fields;
-    if (ref $rec eq 'ARRAY') {
-        @fields = @$rec;
-    } 
-    else {
-        return unless defined $rec;
-        my @fields = $self->{parser}->read_fields($rec);
-        return undef if scalar @fields == 1 and !defined $fields[0];
-    }
-    if ( my $subs = $self->{parser}->{read_sub} ) {
-        for (@$subs) {
-            my($col,$sub) =  @$_;
-            next unless defined $col;
-            my $col_num = $self->{storage}->{col_nums}->{$col};
-            next unless defined $col_num;
-            $fields[$col_num] = &$sub($fields[$col_num]);
-	}
-      }
-    return \@fields;
-}
-sub push_names {
-    my $self = shift;
-    my $col_names = shift || undef;
-    #print "Can't find column names!" unless scalar @$col_names;
-    $self->{storage}->print_col_names( $self->{parser}, $col_names )
-         unless $self->{parser}->{col_names} && $self->parser_type ne 'XML';
-    #    $self->set_col_nums;
-    $self->{parser}->{key} ||= $col_names->[0];
-    #use Data::Dumper; print Dumper $self; exit;
-}
-sub drop           { shift->{storage}->drop(@_); }
-sub truncate       { shift->{storage}->truncate(@_) }
-
-##################################################################
-# END OF DBD STUFF
-##################################################################
-
-##################################################################
-# REQUIRED BY BOTH DBD AND TIEDHASH
-##################################################################
-sub push_row {
-    my $self = shift;
-    die "ERROR: No Column Names!" unless scalar @{$self->col_names};
-    my $requested_cols = [];
-    my @row = @_;
-    if (ref($row[0]) eq 'ARRAY') {
-        $requested_cols = shift @row;
-    }
-    my $rec = $self->{parser}->write_fields(@row) or return undef;
-    return $self->{storage}->push_row( $rec, $self->{parser}, $requested_cols);
-}
-sub push_rowNEW {
-    my $self = shift;
-    #print "PUSHING... ";
-    die "ERROR: No Column Names!" unless scalar @{$self->col_names};
-    my $requested_cols = [];
-    my @row = @_;
-    use Data::Dumper;
-    #print "PUSHING ", Dumper \@row;
-    if (ref($row[0]) eq 'ARRAY') {
-        $requested_cols = shift @row;
-    }
-    my $rec = $self->{parser}->write_fields(@row) or return undef;
-    return $self->{storage}->push_row( $rec, $self->{parser}, $requested_cols);
-}
-sub seek              { shift->{storage}->seek(@_); }
-sub seek_first_record { 
-    my $self=shift;
-    $self->{storage}->seek_first_record($self->{parser});
-}
-sub col_names    {
-    my $self = shift;
-    my $c = $self->{storage}->{col_names};
-    $c = $self->{parser}->{col_names} unless (ref $c eq 'ARRAY') and scalar @$c;
-    $c ||= [];
-}
-sub is_url {
-    my $file = shift;
-    return $file if $file and $file =~ m"^http://|ftp://";
-}
-
-sub adTable {
-    ###########################################################
-    # Patch from Wes Hardaker
-    ###########################################################
-    # my($formatref,$file,$read_mode,$lockMode,$othflags)=@_;
-    my($formatref,$file,$read_mode,$lockMode,$othflags,$tname)=@_;
-    ###########################################################
-    #use Data::Dumper; print Dumper \@_;
-    my($format,$flags);
-    $file ||= '';
-    my $url = is_url($file);
-    $flags = {};
-    $othflags ||= {};
-    if ( ref $formatref eq 'HASH' or $othflags->{data}) {
-        $format = 'Base';
-	$flags = $othflags;
-        if (ref $formatref eq 'HASH') {
-            %$flags  = (%$formatref,%$othflags);
-	} 
-   } 
-   else {
-      ($format,$flags) = split_params($formatref);
-      $othflags ||= {};
-      %$flags = (%$flags,%$othflags);
-    }
-    if ( $flags->{cols} ) {
-        $flags->{col_names} = $flags->{cols};
-        delete $flags->{cols};
-    }
-    if (ref($file) eq 'ARRAY') {
-      if ($format eq 'Mp3' or $format eq 'FileSys') {
-	 $flags->{dirs} = $file;
-      } 
-      else {
-         $flags->{recs} = join '',@$file;
-         $flags->{recs} = $file if $format =~ /ARRAY/i;
-         $flags->{storage} = 'RAM' unless $format eq 'XML';
-         $read_mode = 'u';
-      }
-    }
-    else {
-        $flags->{file} = $file;
-    }
-    if ($format ne 'XML' and ($format eq 'Base' or $url) ) {
-        my $x;
-        $flags->{storage} = 'RAM';
-        delete $flags->{recs};
-        my $ad = AnyData->new( $format, $flags);
-        $format eq 'Base'
-            ? $ad->open_table( $file )
-            : $ad->open_table( $file,  'r',
-                               $ad->{storage}->get_remote_data($file)
-                             );
-        return $ad;
-    }
-    my $ad = AnyData->new( $format, $flags);
-    my $createMode = 0;
-    $createMode = $read_mode if defined $lockMode;
-    $read_mode   = 'c' if $createMode  and $lockMode;
-    $read_mode   = 'u' if !$createMode and $lockMode;
-    $read_mode ||= 'r';
-    $ad->{parser}->{keep_first_line} = 1 
-         if $flags->{col_names} and 'ru' =~ /$read_mode/;
-    #####################################################
-    # Patch from Wes Hardaker
-    #####################################################
-    # $ad->open_table( $file, $read_mode );
-##    $ad->open_table( $file, $read_mode, $tname );
-    $ad->open_table( $file, $read_mode, $tname );
-#    use Data::Dumper; my $x = $ad; delete $x->{parser}->{twig}; delete $x->{parser}->{record_tag}; delete $x->{parser}->{current_element}; print Dumper $x;
-    #####################################################
-    return $ad;
-}
-
-sub open_table     {
-    my $self = shift;
-    $self->{storage}->open_table( $self->{parser}, @_ );
-    my $col_names = $self->col_names();
-    $self->{parser}->{key} ||= '';
-    $self->{parser}->{key} ||= $col_names->[0] if $col_names->[0];
-}
-##################################################################
-
-
-##################################################################
-# TIEDHASH STUFF
-##################################################################
-sub key_col          { shift->{parser}->{key} }
-
-sub fetchrow_hashref {
-    my $self = shift;
-    my $rec = $self->get_undeleted_record or return undef;
-    my  @fields = ref $rec eq 'ARRAY'
-            ? @$rec
-            : $self->{parser}->read_fields($rec);
-    my $col_names = $self->col_names();
-    return undef unless scalar @fields;
-    return undef if scalar @fields == 1 and !defined $fields[0];
-    my $rowhash;
-    @{$rowhash}{@$col_names} = @fields;
-    return ( $rowhash );
-}
-sub get_undeleted_record {
-    my $self = shift;
-    my $rec;
-    my $found=0;
-    return $self->fetch_row if $self->parser_type eq 'XML';
-    while (!$found) {
-        my $test = $rec    = $self->{storage}->file2str($self->{parser});
-        return  if !defined $rec;
-        next if $self->{storage}->is_deleted($self->{parser});
-        next if $self->{parser}->{skip_pattern} 
-            and $rec =~ $self->{parser}->{skip_pattern};
-        last;
-    }
-    return $rec;
-#    return $rec if ref $rec eq 'ARRAY';
-#    return unless $rec;
-#    my @fields = $self->{parser}->read_fields($rec);
-#    return undef if scalar @fields == 1 and !defined $fields[0];
-#    return \@fields;
-}
-sub update_single_row {
-    my $self     = shift;
-    my $oldrow   = shift;
-    my $newvals  = shift;
-    my @colnames = @{ $self->col_names };
-    my @newrow;
-    my $requested_cols = [];
-    for my $i(0..$#colnames) {
-        push @$requested_cols, $colnames[$i] if defined $newvals->{$colnames[$i]};
-        $newrow[$i] = $newvals->{$colnames[$i]};
-        $newrow[$i] = $oldrow->{$colnames[$i]} unless defined $newrow[$i];
-    }
-    unshift @newrow, $requested_cols;
-    $self->{storage}->seek(0,2);
-    $self->push_row( @newrow );
-    return \@newrow;
-}
-sub update_multiple_rows {
-    my $self   = shift;
-    my $key    = shift;
-    my $values = shift;
-    $self->seek_first_record;
-    my @rows_to_update;
-    while (my $row = $self->fetchrow_hashref) {
-        next unless $self->match($row,$key);
-        $self->{parser}->{has_update_function}
-            ? $self->update_single_row($row,$values)
-            : $self->delete_single_row();
-        $self->{parser}->{has_update_function}
-            ? push @rows_to_update,1
-            : push @rows_to_update,$row;
-    }
-    if (!$self->{parser}->{has_update_function}) {
-        for (@rows_to_update) {
-           $self->update_single_row($_,$values);
-	 }
-    }
-    return scalar @rows_to_update;
-}
-sub match {
-    my($self,$row,$key) = @_;
-    if ( ref $key ne 'HASH') {
-        return 0 if !$row->{$self->key_col}
-                 or  $row->{$self->key_col} ne $key;
-        return 1;
-    }
-    my $found = 0;
-    while (my($col,$re)=each %$key) {
-        next unless defined $row->{$col} and is_matched($row->{$col},$re);
-        $found++;
-    }
-    return 1 if $found == scalar keys %$key;
-}
-sub is_matched {
-    my($str,$re)=@_;
-    if (ref $re eq 'Regexp') {
-        return $str =~ /$re/ ? 1 : 0;
-    }
-    my($op,$val);
-    
-    if ( $re and $re =~/^(\S*)\s+(.*)/ ) {
-        $op  = $1;
-        $val = $2;
-    }
-    elsif ($re) {
-        return $str =~ /$re/ ? 1 : 0;
-    }
-    else {
-        return $str eq '' ? 1 : 0;
-    }
-    my $numop = '< > == != <= >=';
-    my $chrop = 'lt gt eq ne le ge';
-    if (!($numop =~ /$op/) and !($chrop =~ /$op/)) {
-        return $str =~ /$re/ ? 1 : 0;
-    }
-    if ($op eq '<' ) { return $str <  $val; }
-    if ($op eq '>' ) { return $str >  $val; }
-    if ($op eq '==') { return $str == $val; }
-    if ($op eq '!=') { return $str != $val; }
-    if ($op eq '<=') { return $str <= $val; }
-    if ($op eq '>=') { return $str >= $val; }
-    if ($op eq 'lt') { return $str lt $val; }
-    if ($op eq 'gt') { return $str gt $val; }
-    if ($op eq 'eq') { return $str eq $val; }
-    if ($op eq 'ne') { return $str ne $val; }
-    if ($op eq 'le') { return $str le $val; }
-    if ($op eq 'ge') { return $str ge $val; }
-}
-sub delete_single_row {
-    my $self = shift;
-#    my $curpos = $self->{storage}->get_pos;
-    $self->{storage}->delete_record($self->{parser});
-#    $self->{storage}->go_pos($curpos);
-    $self->{needs_packing}++;
-}
-sub delete_multiple_rows {
-    my $self   = shift;
-    my $key    = shift;
-    $self->seek_first_record;
-    my $rows_deleted =0;
-    while (my $row = $self->fetchrow_hashref) {
-        next unless $self->match($row,$key);
-        $self->delete_single_row;
-        $rows_deleted++;
-    }
-    return $rows_deleted;
-}
-
-sub adNames { @{ shift->{__colnames}} }
-
-sub adDump {
-    my $table = shift;
-    my $pat   = shift;
-    die "No table defined" unless $table;
-    my $ad = tied(%$table)->{ad};
-    my @cols = @{ $ad->col_names };
-    print "<",join(":", @cols), ">\n";
-    while (my $row = each %$table) {
-        my @row  = map {defined $row->{$_} ? $row->{$_} : ''} @cols;
-        for (@row) { print "[$_]"; }
-        print  "\n";
-    }
-}
-
-sub adRows {
-    my $thash = shift;
-    my %keys  = @_;
-    my $obj   = tied(%$thash);
-    return $obj->adRows(\%keys);
-}
-sub adColumn {
-    my $thash  = shift;
-    my $column = shift;
-    my $flags = shift;
-    my $obj    = tied(%$thash);
-    return $obj->adColumn($column, $flags);
-}
-sub adArray {
-    my($format,$data)=@_;
-    my $t = adTie( $format, $data );
-    my $t1 = tied(%$t);
-    my $ad = $t1->{ad};
-    my $arrayref = $ad->{storage}->{records};
-    unshift @$arrayref, $ad->{storage}->{col_names};
-    return $arrayref;
-}
-##################################################################
-# END OF TIEDHASH STUFF
-##################################################################
-sub parser_type {
-    my $type = ref shift->{parser};
-    $type =~ s/AnyData::Format::(.*)/$1/;
-    return $type;
-}
-sub zpack {
-    my $self = shift;
-    return if $self->{storage}->{no_pack};
-    return if (ref $self->{storage} ) !~ /File$/;
-
-#    return unless $self->{needs_packing};
-#    $self->{needs_packing} = 0;
-    return unless scalar(keys %{ $self->{storage}->{deleted} } );
-    $self->{needs_packing} = 0;
-    #    my @callA = caller 2;
-    #    my @callB = caller 3;
-    #    return if $callA[3] =~ /DBD/;
-    #    return if $callB[3] and $callB[3] =~ /SQL::Statement/;
-    #    return if $self->{parser}->{export_on_close};
-    #print "PACKING";
-    my $bak_file = $self->{storage}->get_file_name . '.bak';
-    my $bak = adTable( 'Text', $bak_file, 'o' );
-    my $bak_fh = $bak->{storage}->get_file_handle;
-    my $fh     = $self->{storage}->get_file_handle;
-    die "Can't pack to backup $!" unless $fh and $bak_fh;
-    # $self->seek_first_record;
-    $fh->seek(0,0) || die $!;
-    #$bak_fh->seek(0,0) || die $!;
-#    while (my $line = $self->get_record) {
-#        next if $self->is_deleted($line);
-    while (my $line = $self->get_undeleted_record) {
-        my $tmpstr = $bak->{parser}->write_fields($line)
-                   . $self->{parser}->{record_sep};
-        $bak_fh->write($tmpstr,length $tmpstr);
-    }
-    $fh->seek(0,0);
-    $fh->truncate(0) || die $!;
-    $bak->seek_first_record;
-    while (<$bak_fh>) {
-        $fh->write($_,length $_);
-    }
-    $fh->close;
-    $bak_fh->close;
-    $self->{doing_pack} = 0;
-    undef $self->{storage}->{deleted};
-}
-
-##########################################################
-#  FUNCTION CALL INTERFACE
-##########################################################
-sub adTie {
-    my($format,$file,$read_mode,$flags)=@_;
-    my $data;
-    if (ref $file eq 'ARRAY' && !$read_mode ) { $read_mode = 'u'; }
-    # ARRAY only {data=>[]};
-    if (scalar @_ == 1){
-        $read_mode = 'o';
-        tie %$data,
-            'AnyData::Storage::TiedHash',
-            adTable($format),
-            $read_mode;
-        return $data;
-    }
-    tie %$data,
-        'AnyData::Storage::TiedHash',
-        adTable($format,$file,$read_mode,undef,$flags),
-        $read_mode;
-    return $data;
-}
-sub adErr {
-    my $hash = shift;
-    my $t = tied(%$hash);
-    my $errstr = $t->{ad}->{parser}->{errstr}
-        || $t->{ad}->{storage}->{errstr};
-    print $errstr if $errstr;
-    return $errstr;
-}
-sub adExport {
-    my $tiedhash  = shift;
-    my($tformat,$tfile,$tflags)=@_;
-    my $ad = tied(%$tiedhash)->{ad};
-    my $sformat = ref $ad->{parser};
-    $sformat =~ s/AnyData::Format:://;
-    $tformat ||= $sformat;
-    if ($tformat eq $sformat and $tformat eq 'XML') {
-      return $ad->{parser}->export($ad->{storage},$tfile,$tflags);
-    }
-    return adConvert('adHash',$ad,$tformat,$tfile,undef,$tflags);
-}
-sub adConvert {
-    my( $source_format, $source_data,
-        $target_format,$target_file_name,
-        $source_flags,$target_flags    )=@_;
-
-    my $target_type = 'STRING';
-       $target_type = 'FILE'  if defined $target_file_name;
-       $target_type = 'ARRAY' if $target_format eq 'ARRAY';
-
-    my $data_type = 'AD-OBJECT';
-       $data_type = 'ARRAY'  if  ref $source_data eq 'ARRAY'
-                            and  ref $source_data->[0] eq 'ARRAY';
-
-    # INIT SOURCE OBJECT
-    my $source_ad;
-    if ($source_format eq 'adHash') {
-        $source_ad = $source_data;
-        undef $source_data;
-    } 
-    else {
-        $source_format = 'CSV' if $source_format =~ /ARRAY/i;
-        $source_ad = adTable(
-             $source_format,$source_data,'r',undef,$source_flags
-        );
-    }
-
-    # GET COLUMN NAMES
-    my @cols;
-    if ( $data_type eq 'ARRAY') {
-        @cols = @{ shift @{ $source_data  } };
-    }
-    else {
-        @cols = @{ $source_ad->col_names };
-    }
-
-
-    # insert storable here
-    if ('XML HTMLtable' =~ /$target_format/) {
-        $target_flags->{col_names} = join ',', at cols;
-        my $target_ad = adTable(
-            $target_format,$target_file_name,'o',undef,$target_flags
-        );
-        if ($data_type eq 'ARRAY' ) {
-             for my $row(@$source_data) {
-                 my @fields=$source_ad->str2ary($row);
-                 $target_ad->push_row( $source_ad->str2ary(\@fields) );
-             }
-             unshift @$source_data, \@cols;
-             return $target_ad->export($target_file_name);
-        }
-        $source_ad->seek_first_record;
-        while (my $row = $source_ad->get_undeleted_record) {
-            $target_ad->push_row( $source_ad->str2ary($row) );
-        }
-        return $target_ad->export($target_file_name);
-    }
-
-    my($target_ad,$fh);
-    ### INIT TARGET OBJECT
-    if ($target_type eq 'FILE') {
-        $target_ad = adTable(
-            $target_format,$target_file_name,'c',undef,$target_flags
-        );
-        $fh = $target_ad->{storage}->get_file_handle;
-    }
-    elsif ($target_type eq 'STRING') {
-        $target_ad = AnyData->new( $target_format,$target_flags);
-    }
-
-    my($str,$aryref);
-    ### GET COLUMN NAMES
-    if ( !$target_ad->{parser}->{no_col_print} ) {
-        if ($target_type eq 'ARRAY') {
-            push @$aryref, \@cols;
-        }
-        else {
-        $str = $target_ad->{parser}->write_fields(@cols);
-        $str =~ s/ /,/g if $target_format eq 'Fixed';
-        if ($target_type eq 'FILE') {
-            $fh->write($str,length $str);
-	}
-        if ($target_type eq 'STRING') {
-            $str = $target_ad->{parser}->write_fields(@cols);
-	}
-	}
-    }
-
-    # GET DATA
-    if ($data_type eq 'ARRAY') {
-      for my $row(@$source_data) {
-        my @fields = $source_ad->str2ary($row);
-        my $tmpstr = $target_ad->{parser}->write_fields(@fields);
-        # print $tmpstr if $check;
-        $fh->write($tmpstr,length $tmpstr) if $target_type eq 'FILE';
-        $str .=  $tmpstr if $target_type eq 'STRING';
-      }
-      unshift @$source_data, \@cols;
-      return $str if $target_format ne 'ARRAY';
-      return $aryref;
-    }
-    $source_ad->seek_first_record; # unless $source_format eq 'XML';
-    while (my $row = $source_ad->get_undeleted_record) {
-        if ($target_format eq 'ARRAY') {
-            push @$aryref,$row if $target_format eq 'ARRAY';
-            next;
-        }
-        my @fields = $source_ad->str2ary($row);
-        my $tmpstr = $target_ad->{parser}->write_fields(@fields);
-        $str .= $target_type eq 'FILE'
-           ? $fh->write($tmpstr,length $tmpstr)
-           : $tmpstr;
-    }
-    return $str if $target_format ne 'ARRAY';
-    return $aryref;
-}
-
-#    if ('Storable' =~ /$target_format/) {
-#        $target_flags->{col_names} = join ',', at cols;
-#        $target_ad = adTable(
-#            $target_format,$target_file_name,'c',undef,$target_flags
-#        );
-#        if (ref $source_data && !$data) {
-#            for my $row(@$source_data) {
-#                push @$data,$row;
-#            }
-#        }
-#        elsif (!$data) {
-#            $source_ad->seek_first_record;
-#            while (my $row = $source_ad->fetch_row) {
-#                push @$data, $row;
-#           }
-#	}
-#        unshift @$data, \@cols;
-#        return $target_ad->{parser}->export($data,$target_file_name);
-#  }
-
-sub str2ary {
-    my($ad,$row) = @_;
-    return @$row if ref $row eq 'ARRAY';
-    return $ad->{parser}->read_fields($row);
-}
-sub ad_string {
-    my($formatref, at fields) = @_;
-    my($format,$flags) = split_params($formatref);
-# &dump($formatref); print "<$format>"; &dump($flags) if $flags;
-    #$formatref =~ s/(.*)/$1/;
-    my $ad = AnyData->new( $format, $flags );
-    return $ad->{parser}->write_fields(@fields);
-#    return $ad->write_fields(@fields);
-}
-
-sub ad_fields {
-    my($formatref,$str,$flags) = @_;
-#    my($format,$flags) = split_params($formatref);
-#    my $ad = AnyData::new( $format, $flags );
-    my $ad = AnyData->new( $formatref, $flags );
-    return $ad->{parser}->read_fields($str);
-}
-
-sub ad_convert_str {
-    my($source_formatref,$target_formatref,$str) = @_;
-    my($source_format,$source_flags) = split_params($source_formatref);
-    my($target_format,$target_flags) = split_params($target_formatref);
-    my $source_ad = AnyData->new( $source_format,$source_flags);
-    my $target_ad = AnyData->new( $target_format,$target_flags);
-    my @fields = $source_ad->read_fields($str);
-    return $target_ad->write_fields( @fields );
-}
-
-#########################################################
-# UTILITY METHODS
-#########################################################
-#
-# For all methods that have $format as a parameter,
-# $format can be either a string name of a format e.g. 'CSV'
-# or a hashref of the format and flags for that format e.g.
-# { format => 'FixedWidth', pattern=>'A1 A3 A2' }
-#
-# given this parameter, this method returns $format and $flags
-# setting $flags to {} if none are given
-#
-sub split_params {
-    my $source_formatref = shift;
-    my $source_flags = {};
-    my $source_format  = $source_formatref;
-    if (ref $source_formatref eq 'HASH') {
-      while (my($k,$v)=each %$source_formatref) {
-           ($source_format,$source_flags) = ($k,$v);
-      }
-    }
-    #use Data::Dumper;
-    return( $source_format, $source_flags);
-}
-sub dump {
-    my $var = shift;
-    my $name = ref($var);
-    #use Data::Dumper;
-    $Data::Dumper::Indent = 1;
-    $Data::Dumper::Useqq  = 0;
-    print Data::Dumper->new([$var],[$name])->Dump();
-}
-
-###########################################################################
-# START OF DOCUMENTATION
-###########################################################################
-
-=pod
-
-=head1 NAME
-
-AnyData - easy access to data in many formats
-
-=head1 SYNOPSIS
-
- use AnyData;
- my $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
-
-=head1 DESCRIPTION
-
-The rather wacky idea behind this module and its sister module
-DBD::AnyData is that any data, regardless of source or format should
-be accessible and modifiable with the same simple set of methods.
-This module provides a multidimensional 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 flat files (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.
-
-=head1 PREREQUISITES
-
-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.
-
-=head1 USAGE
-
-The AnyData module imports eight methods (functions):
-
-=for test ignore
-
-  adTie()     -- create a new table or open an existing table
-  adExport()  -- save an existing table in a specified format
-  adConvert() -- convert data in one format into another format
-  adFormats() -- list available formats
-  adNames()   -- get the column names of a table
-  adRows()    -- get the number of rows in a table or query
-  adDump()    -- display the data formatted as an array of rows
-  adColumn()  -- group values in a single column
-
-The adTie() command returns a special tied hash.  The tied hash can
-then be used to access and/or modify data.  See below for details
-
-With the exception of the XML, HTMLtable, and ARRAY formats, the
-adTie() command saves all modifications of the data directly to file
-as they are made.  With XML and HTMLtable, you must make your
-modifications in memory and then explicitly save them to file with
-adExport().
-
-=head2 adTie()
-
- my $table = adTie( $format, $data, $open_mode, $flags );
-
-The adTie() command creates a reference to a multidimensional tied hash. In its simplest form, it simply reads a file in a specified format into the tied hash:
-
- my $table = adTie( $format, $file );
-
-$format is the name of any supported format 'CSV','Fixed','Passwd', etc.
-$file is the name of a relative or absolute path to a local file
-
-e.g. 
-     my $table = adTie( 'CSV', '/usr/me/myfile.csv' );
-
-this creates a tied hash called $table by reading data in the
-CSV (comma separated values) format from the file 'myfile.csv'.
-
-The hash reference resulting from adTie() can be accessed and modified as follows:
-
- use AnyData;
- my $table = adTie( $format, $file );
- $table->{$key}->{$column};                       # select a value
- $table->{$key} = {$col1=>$val1,$col2=>$val2...}; # update a row
- delete $table->{$key};                           # delete a row
- while(my $row = each %$table) {                  # loop through rows
-   print $row->{$col1} if $row->{$col2} ne 'baz';
- }
-
-The thing returned by adTie ($table in the example) is not an object,
-it is a reference to a tied hash. This means that hash operations
-such as exists, values, keys, may be used, keeping in mind that this
-is a *reference* to a tied hash so the syntax would be
-
-    for( keys %$table ) {...}
-    for( values %$table ) {...}
-
-Also keep in mind that if the table is really large, you probably do
-not want to use keys and values because they create arrays in memory
-containing data from every row in the table.  Instead use 'each' as
-shown above since that cycles through the file one record at a time
-and never puts the entire table into memory.
-
-It is also possible to use more advanced searching on the hash, see "Multiple Row Operations" below.
-
-In addition to the simple adTie($format,$file), there are other ways to specify additional information in the adTie() command.  The full syntax is:
-
- my $table = adTie( $format, $data, $open_mode, $flags );
-
- The $data parameter allows you to read data from remote files accessible by
- http or ftp, see "Using Remote Files" below.  It also allows you to treat
- strings and arrays as data sources without needing a file at all, see
- "Working with Strings and Arrays" below.
-
-The optional $mode parameter defaults to 'r' if none is supplied or must be
-one of
-
- 'r' read      # read only access
- 'u' update    # read/write access
- 'c' create    # create a new file unless it already exists
- 'o' overwrite # create a new file, overwriting any that already exist
-
-The $flags parameter allows you to specify additional information such as column names.  See the sections in "Further Details" below.
-
-With the exception of the XML, HTMLtable, and ARRAY formats, the
-adTie() command saves all modifications of the data directly to file
-as they are made.  With XML and HTMLtable, you must make your
-modifications in memory and then explicitly save them to file with
-adExport().
-
-=head2 adConvert()
-
- adConvert( $format1, $data1, $format2, $file2, $flags1, $flags2 );
-
- or
-
- print adConvert( $format1, $data1, $format2, undef, $flags1, $flags2 );
-
- or
-
- my $aryref = adConvert( $format1, $data1, 'ARRAY', undef, $flags1 );
-
- This method converts data in any supported format into any other supported
- format.  The resulting data may either be saved to a file (if $file2 is
- supplied as a parameter) or sent back as  a string to e.g. print the data
- to the screen in the new format (if no $file2 is supplied), or sent back
- as an array reference if $format2 is 'ARRAY'.
-
- Some examples:
-
-   # convert a CSV file into an XML file
-   #
-   adConvert('CSV','foo.csv','XML','foo.xml');
-
-   # convert a CSV file into an HTML table and print it to the screen
-   #
-   print adConvert('CSV','foo.csv','HTMLtable');
-
-   # convert an XML string into a CSV file
-   #
-   adConvert('XML', ["<x><motto id='perl'>TIMTOWTDI</motto></x>"],
-             'CSV','foo.csv'
-            );
-
-   # convert an array reference into an XML file
-   #
-   adConvert('ARRAY', [['id','motto'],['perl','TIMTOWTDI']],
-             'XML','foo.xml'
-            );
-
-   # convert an XML file into an array reference
-   #
-   my $aryref = adConvert('XML','foo.xml','ARRAY');
-
- See section below "Using strings and arrays" for details.
-
-=head2 adExport()
-
- adExport( $table, $format, $file, $flags );
-
- or
-
- print adExport( $table, $format );
-
- or
-
- my $aryref = adExport( $table, 'ARRAY' );
-
- This method converts an existing tied hash into another format and/or
- saves the tied hash as a file in the specified format.
-
- Some examples:
-
-   all assume a previous call to my $table= adTie(...);
-
-   # export table to an XML file
-   #
-   adExport($table','XML','foo.xml');
-
-   # export table to an HTML string and print it to the screen
-   #
-   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::Parser) and you do not have the additional modules installed, the format will not work even if listed by this command.  Otherwise, all formats should work as described in this documentation.
-
-=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.
-
- Included below are only some of the more important details of the
- specific parsers.
-
-=over
-
-=item Fixed Format
-
-When using the Fixed format for fixed length records you
-must always specify a pattern indicating the lengths of the fields.
-This should be a string as would be passed to the unpack() function
-to unpack the records in your Fixed length definition:
-
- my $t = adTie( 'Fixed', $file, 'r', {pattern=>'A3 A7 A9'} );
-
-If you want the column names to appear on the first line of a Fixed
-file, they should be in comma-separated format, not in Fixed format.
-This is different from other formats which use their own format to
-display the column names on the first line.  This is necessary because
-the name of the column might be longer than the length of the column.
-
-=item XML Format
-
- The XML format does not allow you to specify column names as a flag,
- rather you specify a "record_tag" and the column names are determined
- from the contents of the tag.  If no record_tag is specified, the
- record tag will be assumed to be the first child of the root of the
- XML tree.  That child and its structure will be determined from the
- DTD if there is one, or from the first occurring record if there is
- no DTD.
-
-For simple XML, no flags are necessary:
-
- <table>
-    <row row_id="1"><name>Joe</name><location>Seattle</location></row>
-    <row row_id="2"><name>Sue</name><location>Portland</location></row>
- </table>
-
-The record_tag will default to the first child, namely "row".  The column
-names will be generated from the attributes of the record tag and all of
-the tags included under the record tag, so the column names in this
-example will be "row_id","name","location".
-
-If the record_tag is not the first child, you will need to specify it.  For example:
-
- <db>
-   <table table_id="1">
-     <row row_id="1"><name>Joe</name><location>Seattle</location></row>
-     <row row_id="2"><name>Sue</name><location>Portland</location></row>
-   </table>
-   <table table_id="2">
-     <row row_id="1"><name>Bob</name><location>Boise</location></row>
-     <row row_id="2"><name>Bev</name><location>Billings</location></row>
-   </table>
- </db>
-
-In this case you will need to specify "row" as the record_tag since it is not the first child of the tree.  The column names will be generated from the attributes of row's parent (if the parent is not the root), from row's attributes
-and sub tags, i.e. "table_id","row_id","name","location".
-
-When exporting XML, you can specify a DTD to control the output.  For example, if you import a table from CSV or from an Array, you can output as XML and specify which of the columns become tags and which become attributes and also specify the nesting of the tags in your DTD.
-
-The XML format parser is built on top of Michel Rodriguez's excellent XML::Twig which is itself based on XML::Parser.  Parameters to either of those modules may be passed in the flags for adTie() and the other commands including the "prettyPrint" flag to specify how the output XML is displayed and things like ProtocolEncoding.  ProtocolEncoding defaults to 'ISO-8859-1', all other flags keep the defaults of XML::Twig and XML::Parser.  See the documentation of those modules for details;
-
- CAUTION: Unlike other formats, the XML format does not save changes to
- the file as they are entered, but only saves the changes when you explicitly
- request them to be saved with the adExport() command.
-
-=item HTMLtable Format
-
- This format is based on Matt Sisk's excelletn HTML::TableExtract.
-
- It can be used to read an existing table from an html page, or to
- create a new HTML table from any data source.
-
- You may control which table in an HTML page is used with the column_names,
- depth and count flags.
-
- If a column_names flag is passed, the first table that contains those names
- as the cells in a row will be selected.
-
- If depth and or count parameters are passed, it will look for tables as
- specified in the HTML::TableExtract documentation.
-
- If none of column_names, depth, or count flags are passed, the first table
- encountered in the file will be the table selected and its first row will
- be used to determine the column names for the table.
-
- When exporting to an HTMLtable, you may pass flags to specify properties
- of the whole table (table_flags), the top row containing the column names
- (top_row_flags), and the data rows (data_row_flags).  These flags follow
- the syntax of CGI.pm table constructors, e.g.:
-
- print adExport( $table, 'HTMLtable', {
-     table_flags    => {Border=>3,bgColor=>'blue'};
-     top_row_flags  => {bgColor=>'red'};
-     data_row_flags => {valign='top'};
- });
-
- The table_flags will default to {Border=>1,bgColor=>'white'} if none
- are specified.
-
- The top_row_flags will default to {bgColor=>'#c0c0c0'} if none are
- specified;
-
- The data_row_flags will be empty if none are specified.
-
- In other words, if no flags are specified the table will print out with
- a border of 1, the column headings in gray, and the data rows in white.
-
- CAUTION: This module will *not* preserve anything in the html file except
- the selected table so if your file contains more than the selected table,
- you will want to use adTie() to read the table and then adExport() to write
- the table to a different file.  When using the HTMLtable format, this is the
- only way to preserve changes to the data, the adTie() command will *not*
- write to a file.
-
-=back
-
-=head2 Multiple Row Operations
-
-The AnyData hash returned by adTie() may use either single values as keys, or a reference to a hash of comparisons as a key.  If the key to the hash is a single value, the hash operates on a single row but if the key to the hash is itself a hash reference, the hash operates on a group of rows.
-
- my $num_deleted = delete $table->{Sue};
-
-This example deletes a single row where the key column has the value 'Sue'.  If multiple rows have the value 'Sue' in that column, only the first is deleted.  It uses a simple string as a key, therefore it operates on only a single row.
-
- my $num_deleted = delete $table->{ {name=>'Sue'} };
-
-This example deletes all rows where the column 'name' is equal to 'Sue'.  It uses a hashref as a key and therefore operates on multiple rows.
-
-The hashref used in this example is a single column comparison but the hashref could also include multiple column comparisons.  This deletes all rows where the the values listed for the country, gender, and age columns are equal to those specified:
-
-  my $num_deleted = delete $table->{{ country => 'us',
-                                       gender => 'm',
-                                          age => '25'
-                                   }}
-
-
-In addition to simple strings, the values may be specified as regular expressions or as numeric or alphabetic comparisons.  This will delete all North American males under the age of 25:
-
-  my $num_deleted = delete $table->{{ country => qr/mx|us|ca/,
-                                      gender  => 'm',
-                                      age     => '< 25'
-                                   }}
-
-If numeric or alphabetic comparisons are used, they should be a string with the comparison operator separated from the value by a space, e.g. '> 4' or 'lt b'.
-
-This kind of search hashref can be used not only to delete multiple rows, but also to update rows.  In fact you *must* use a hashref key in order to update your table.  Updating is the only operation that can not be done with a single string key.
-
-The search hashref can be used with a select statement, in which case it returns a reference to an array of rows matching the criteria:
-
- my $male_players = $table->{{gender=>'m'}};
- for my $player( @$male_players ) { print $player->{name},"\n" }
-
-This should be used with caution with a large table since it gathers all of the selected rows into an array in memory.  Again, 'each' is a much better way for large tables.  This accomplishes the same thing as the example above, but without ever pulling more than a row into memory at a time:
-
- while( my $row= each %$table ) {
-   print $row->{name}, "\n" if $row->{gender}=>'m';
- }
-
-Search criteria for multiple rows can also be used with the adRows() function:
-
-  my $num_of_women = adRows( $table, gender => 'w' );
-
-That does *not* pull the entire table into memory, it counts the rows a record at a time.
-
-=head2 Using Remote Files
-
-If the first file parameter of adTie() or adConvert() begins with "http://" or "ftp://", the file is treated as a remote URL and the LWP module is called behind the scenes to fetch the file.  If the files are in an area that requires authentication, that may be supplied in the $flags parameter.
-
-For example:
-
-  # read a remote file and access it via a tied hash
-  #
-  my $table = adTie( 'XML', 'http://www.foo.edu/bar.xml' );
-
-  # same with username/password
-  #
-  my $table = ( 'XML', 'ftp://www.foo.edu/pub/bar.xml', 'r'
-                { user => 'me', pass => 'x7dy4'
-              );
-
-  # read a remote file, convert it to an HTML table, and print it
-  #
-  print adConvert( 'XML', 'ftp://www.foo.edu/pub/bar.xml', 'HTMLtable' );
-
-=head2 Using Strings and Arrays
-
-Strings and arrays may be used as either the source of data input or as the target of data output.  Strings should be passed as the only element of an array reference (in other words, inside square brackets).  Arrays should be a reference to an array whose first element is a reference to an array of column names and whose succeeding elements are references to arrays of row values.
-
-For example:
-
-  my $table = adTie( 'XML', ["<x><motto id='perl'>TIMTOWTDI</motto></x>"] );
-
-  This uses the XML format to parse the supplied string and returns a tied
-  hash to the resulting table.
-
-
-  my $table = adTie( 'ARRAY', [['id','motto'],['perl','TIMTOWTDI']] );
-
-  This uses the column names "id" and "motto" and the supplied row values
-  and returns a tied hash to the resulting table.
-
-It is also possible to use an empty array to create a new empty tied hash in any format, for example:
-
-  my $table = adTie('XML',[],'c');
-
-  creates a new empty tied hash;
-
-See adConvert() and adExport() for further examples of using strings and arrays.
-
-=head2 Ties, Flocks, I/O, and Atomicity
-
-AnyData provides flocking which works under the limitations of flock -- that it only works if other processes accessing the files are also using flock and only on platforms that support flock.  See the flock() man page for details.
-
-Here is what the user supplied open modes actually do:
-
- r = read only  (LOCK_SH)  O_RDONLY
- u = update     (LOCK_EX)  O_RDWR
- c = create     (LOCK_EX)  O_CREAT | O_RDWR | O_EXCL
- o = overwrite  (LOCK_EX)  O_CREAT | O_RDWR | O_TRUNC
-
-When you use something like "my $table = adTie(...)", it opens
-the file with a lock and leaves the file and lock open until
-1) the hash variable ($table) goes out of scope or 2) the
-hash is undefined (e.g. "undef $table") or 3) the hash is
-re-assigned to another tie.  In all cases the file is closed
-and the lock released.
-
-If adTie is called without creating a tied hash variable, the file
-is closed and the lock released immediately after the call to adTie.
-
- For example:  print adTie('XML','foo.xml')->{main_office}->{phone}.
-
- That obtains a shared lock, opens the file, retrieves the one value
- requested, closes the file and releases the lock.
-
-These two examples accomplish the same thing but the first example
-opens the file once, does all of the deletions, keeping the exclusive
-lock in place until they are all done, then closes the
-file.  The second example opens and closes the file three times,
-once for each deletion and releases the exclusive lock between each
-deletion:
-
- 1. my $t = adTie('Pipe','games.db','u');
-    delete $t->{"user$_"} for (0..3);
-    undef $t; # closes file and releases lock
-
- 2. delete adTie('Pipe','games.db','u')->{"user$_"} for (0..3);
-    # no undef needed since no hash variable created
-
-=head2 Deletions and Packing
-
-In order to save time and to prevent having to do writes anywhere except at the end of the file, deletions and updates are *not* done at the time of issuing a delete command.  Rather when the user does a delete, the position of the deleted record is stored in a hash and when the file is saved to disk, the deletions are only then physically removed by packing the entire database.  Updates are done by inserting the new record at the end of the file and marking the old record for deletion.  [...]
-
-=head1 MORE HELP
-
-See the README file and the test.pl included with the module
-for further examples.
-
-See the AnyData/Format/*.pm PODs for further details of specific
-formats.
-
-For further support, please use comp.lang.perl.modules
-
-=head1 ACKNOWLEDGEMENTS
-
-Special thanks to Andy Duncan, Tom Lowery, Randal Schwartz, Michel Rodriguez, Jochen Wiedmann, Tim Bunce, Alligator Descartes, Mathew Persico, Chris Nandor, Malcom Cook and to many others on the DBI mailing lists and the clp* newsgroups.
-
-=head1 AUTHOR & COPYRIGHT
-
- Jeff Zucker <jeff at vpservices.com>
-
- This module is copyright (c), 2000 by Jeff Zucker.
- Some changes (c) 2012 Sven Dowideit L<mailto:SvenDowideit at fosiki.com>
- It may be freely distributed under the same terms as Perl itself.
-
-=cut
-
-################################
-# END OF AnyData
-################################
-1;
+##################################################################
+package AnyData;
+###################################################################
+#
+#   This module is copyright (c), 2000 by Jeff Zucker
+#   All rights reserved.
+#
+###################################################################
+use strict;
+use warnings;
+require Exporter;
+use AnyData::Storage::TiedHash;
+use vars qw( @ISA @EXPORT $VERSION );
+ at ISA = qw(Exporter);
+ at EXPORT = qw(  adConvert adTie adRows adColumn adExport adDump adNames adFormats);
+#@EXPORT = qw(  ad_fields adTable adErr adArray);
+
+$VERSION = '0.12';
+
+sub new {
+   my $class   = shift;
+   my $format  = shift;
+   my $flags   = shift || {};
+   my $del_marker = "\0";
+   $format = 'CSV' if $format eq 'ARRAY';
+   my $parser_name = 'AnyData/Format/' . $format . '.pm';
+   eval { require $parser_name; };
+   die "Error Opening File-Parser: $@" if $@;
+   $parser_name =~ s#/#::#g;
+   $parser_name =~ s#\.pm$##g;
+    my $col_names = $flags->{col_names} || undef;
+    if ($col_names) {
+        my @cols;
+        @cols = ref $col_names eq 'ARRAY'
+          ? @$col_names
+          : split ',',$col_names;
+        $flags->{col_names} = \@cols;
+   }
+   $flags->{del_marker} = $del_marker;
+   $flags->{records}   ||= $flags->{data};
+   $flags->{field_sep} ||= $flags->{sep_char}   ||= $flags->{ad_sep_char};
+   $flags->{quote}     ||= $flags->{quote_char} ||= $flags->{ad_quote_char};
+   $flags->{escape}    ||= $flags->{escape_char}||= $flags->{ad_escape_char};
+   $flags->{record_sep}||= $flags->{eol}        ||= $flags->{ad_eol};
+   # $flags->{skip_first_row}
+   my $parser    = $parser_name->new ($flags);
+   if ($parser->{col_names} && !$col_names) {
+        my @cols;
+        @cols = ref $parser->{col_names} eq 'ARRAY'
+          ? @{$parser->{col_names}}
+          : split ',',$parser->{col_names};
+        $flags->{col_names} = \@cols;
+        $parser->{col_names} = \@cols;
+   }
+   my $storage_name = $flags->{storage}
+                   || $parser->storage_type()
+                   || 'File';
+   $storage_name = "AnyData/Storage/$storage_name.pm";
+   eval { require $storage_name; };
+   die "Error Opening Storage Module: $@" if $@;
+   $storage_name =~ s#/#::#g;
+   $storage_name =~ s#\.pm$##g;
+   my $storage   = new $storage_name({del_marker=>$del_marker,%$flags});
+   if ($storage_name =~ 'PassThru') {
+       $storage->{parser} = $parser;
+       $parser->{del_marker} = "\0";
+       $parser->{url} = $flags->{file} 
+                      if $flags->{file} and $flags->{file} =~ /http:|ftp:/;
+   }
+   my $self = {
+       storage => $storage,
+       parser  => $parser,
+   };
+   return( bless($self,$class) );
+}
+
+sub adFormats {
+    my @formats;
+    for my $dir(@INC) {
+        my $format_dir = "$dir/AnyData/Format";
+        if ( -d $format_dir ) {
+            local *D;
+            opendir(D,$format_dir);
+            @formats = grep {/\.pm$/} readdir(D);
+            last;
+        }
+    }
+    unshift @formats,'ARRAY';
+    @formats = map {s/^(.*)\.pm$/$1/;$_} @formats;
+    return @formats;
+}
+
+sub export {
+    my $self=shift;
+    my $fh   = $self->{storage}->{fh};
+    my $mode = $self->{storage}->{open_mode} || 'r';
+#    if ( $self->{parser}->{export_on_close}
+#      && $self->{storage}->{fh}
+#      && $mode ne 'r'
+#     ){
+      return $self->{parser}->export( $self->{storage}, @_ );
+#    }
+}
+sub DESTROY {
+    my $self=shift;
+#    $self->export;
+    $self->zpack;
+    #print "AD DESTROYED ";
+}
+##########################################
+# DBD STUFF
+##########################################
+# required only for DBD-AnyData
+##########################################
+sub prep_dbd_table {
+    my $self       = shift;
+    my $tname      = shift;
+    my $createMode = shift;
+    my $col_names;
+    my $col_nums;
+    my $first_row_pos;
+    if (!$createMode) {
+        $col_names     = $self->{storage}->get_col_names($self->{parser});
+        $col_nums      = $self->{storage}->set_col_nums();
+        $first_row_pos = $self->{storage}->{first_row_pos};
+    }
+    die "ERROR: No Column Names!:", $self->{storage}->{open_mode}
+     if (!$col_names || !scalar @$col_names) 
+     && 'ru' =~ $self->{storage}->{open_mode}
+     && !$createMode eq 'o';
+    my $table = {
+        NAME          => $tname,
+        DATA          => [],
+        CURRENT_ROW   => 0,
+        col_names     => $col_names,
+        col_nums      => $col_nums,
+        first_row_pos => $first_row_pos,
+        fh            => $self->{storage}->get_file_handle,
+        file          => $self->{storage}->get_file_name,
+        ad            => $self,
+    };
+    #use Data::Dumper; print Dumper $table;
+    return $table;
+}
+sub fetch_row   {
+    my $self   = shift;
+    my $requested_cols = shift || [];
+    my $rec;
+    if ( $self->{parser}->{skip_pattern} ) {
+        my $found;
+        while (!$found) {
+            $rec = $self->{storage}->file2str($self->{parser},$requested_cols);
+            last if !defined $rec;
+            next if $rec =~ $self->{parser}->{skip_pattern};
+            last;
+	}
+    }
+    else {
+        $rec = $self->{storage}->file2str($self->{parser},$requested_cols);
+    }
+    return $rec if ref $rec eq 'ARRAY';
+    return unless $rec;
+    my @fields = $self->{parser}->read_fields($rec);
+    return undef if scalar @fields == 1 and !defined $fields[0];
+    return \@fields;
+}
+sub fetch_rowNEW   {
+    my $self   = shift;
+    my $requested_cols = shift || [];
+    my $rec    = $self->{storage}->file2str($self->{parser},$requested_cols);
+    my @fields;
+    if (ref $rec eq 'ARRAY') {
+        @fields = @$rec;
+    } 
+    else {
+        return unless defined $rec;
+        my @fields = $self->{parser}->read_fields($rec);
+        return undef if scalar @fields == 1 and !defined $fields[0];
+    }
+    if ( my $subs = $self->{parser}->{read_sub} ) {
+        for (@$subs) {
+            my($col,$sub) =  @$_;
+            next unless defined $col;
+            my $col_num = $self->{storage}->{col_nums}->{$col};
+            next unless defined $col_num;
+            $fields[$col_num] = &$sub($fields[$col_num]);
+	}
+      }
+    return \@fields;
+}
+sub push_names {
+    my $self = shift;
+    my $col_names = shift || undef;
+    #print "Can't find column names!" unless scalar @$col_names;
+    $self->{storage}->print_col_names( $self->{parser}, $col_names )
+         unless $self->{parser}->{col_names} && $self->parser_type ne 'XML';
+    #    $self->set_col_nums;
+    $self->{parser}->{key} ||= $col_names->[0];
+    #use Data::Dumper; print Dumper $self; exit;
+}
+sub drop           { shift->{storage}->drop(@_); }
+sub truncate       { shift->{storage}->truncate(@_) }
+
+##################################################################
+# END OF DBD STUFF
+##################################################################
+
+##################################################################
+# REQUIRED BY BOTH DBD AND TIEDHASH
+##################################################################
+sub push_row {
+    my $self = shift;
+    die "ERROR: No Column Names!" unless scalar @{$self->col_names};
+    my $requested_cols = [];
+    my @row = @_;
+    if (ref($row[0]) eq 'ARRAY') {
+        $requested_cols = shift @row;
+    }
+    my $rec = $self->{parser}->write_fields(@row) or return undef;
+    return $self->{storage}->push_row( $rec, $self->{parser}, $requested_cols);
+}
+sub push_rowNEW {
+    my $self = shift;
+    #print "PUSHING... ";
+    die "ERROR: No Column Names!" unless scalar @{$self->col_names};
+    my $requested_cols = [];
+    my @row = @_;
+    use Data::Dumper;
+    #print "PUSHING ", Dumper \@row;
+    if (ref($row[0]) eq 'ARRAY') {
+        $requested_cols = shift @row;
+    }
+    my $rec = $self->{parser}->write_fields(@row) or return undef;
+    return $self->{storage}->push_row( $rec, $self->{parser}, $requested_cols);
+}
+sub seek              { shift->{storage}->seek(@_); }
+sub seek_first_record { 
+    my $self=shift;
+    $self->{storage}->seek_first_record($self->{parser});
+}
+sub col_names    {
+    my $self = shift;
+    my $c = $self->{storage}->{col_names};
+    $c = $self->{parser}->{col_names} unless (ref $c eq 'ARRAY') and scalar @$c;
+    $c ||= [];
+}
+sub is_url {
+    my $file = shift;
+    return $file if $file and $file =~ m"^http://|ftp://";
+}
+
+sub adTable {
+    ###########################################################
+    # Patch from Wes Hardaker
+    ###########################################################
+    # my($formatref,$file,$read_mode,$lockMode,$othflags)=@_;
+    my($formatref,$file,$read_mode,$lockMode,$othflags,$tname)=@_;
+    ###########################################################
+    #use Data::Dumper; print Dumper \@_;
+    my($format,$flags);
+    $file ||= '';
+    my $url = is_url($file);
+    $flags = {};
+    $othflags ||= {};
+    if ( ref $formatref eq 'HASH' or $othflags->{data}) {
+        $format = 'Base';
+	$flags = $othflags;
+        if (ref $formatref eq 'HASH') {
+            %$flags  = (%$formatref,%$othflags);
+	} 
+   } 
+   else {
+      ($format,$flags) = split_params($formatref);
+      $othflags ||= {};
+      %$flags = (%$flags,%$othflags);
+    }
+    if ( $flags->{cols} ) {
+        $flags->{col_names} = $flags->{cols};
+        delete $flags->{cols};
+    }
+    if (ref($file) eq 'ARRAY') {
+      if ($format eq 'Mp3' or $format eq 'FileSys') {
+	 $flags->{dirs} = $file;
+      } 
+      else {
+         $flags->{recs} = join '',@$file;
+         $flags->{recs} = $file if $format =~ /ARRAY/i;
+         $flags->{storage} = 'RAM' unless $format eq 'XML';
+         $read_mode = 'u';
+      }
+    }
+    else {
+        $flags->{file} = $file;
+    }
+    if ($format ne 'XML' and ($format eq 'Base' or $url) ) {
+        my $x;
+        $flags->{storage} = 'RAM';
+        delete $flags->{recs};
+        my $ad = AnyData->new( $format, $flags);
+        $format eq 'Base'
+            ? $ad->open_table( $file )
+            : $ad->open_table( $file,  'r',
+                               $ad->{storage}->get_remote_data($file)
+                             );
+        return $ad;
+    }
+    my $ad = AnyData->new( $format, $flags);
+    my $createMode = 0;
+    $createMode = $read_mode if defined $lockMode;
+    $read_mode   = 'c' if $createMode  and $lockMode;
+    $read_mode   = 'u' if !$createMode and $lockMode;
+    $read_mode ||= 'r';
+    $ad->{parser}->{keep_first_line} = 1 
+         if $flags->{col_names} and 'ru' =~ /$read_mode/;
+    #####################################################
+    # Patch from Wes Hardaker
+    #####################################################
+    # $ad->open_table( $file, $read_mode );
+##    $ad->open_table( $file, $read_mode, $tname );
+    $ad->open_table( $file, $read_mode, $tname );
+#    use Data::Dumper; my $x = $ad; delete $x->{parser}->{twig}; delete $x->{parser}->{record_tag}; delete $x->{parser}->{current_element}; print Dumper $x;
+    #####################################################
+    return $ad;
+}
+
+sub open_table     {
+    my $self = shift;
+    $self->{storage}->open_table( $self->{parser}, @_ );
+    my $col_names = $self->col_names();
+    $self->{parser}->{key} ||= '';
+    $self->{parser}->{key} ||= $col_names->[0] if $col_names->[0];
+}
+##################################################################
+
+
+##################################################################
+# TIEDHASH STUFF
+##################################################################
+sub key_col          { shift->{parser}->{key} }
+
+sub fetchrow_hashref {
+    my $self = shift;
+    my $rec = $self->get_undeleted_record or return undef;
+    my  @fields = ref $rec eq 'ARRAY'
+            ? @$rec
+            : $self->{parser}->read_fields($rec);
+    my $col_names = $self->col_names();
+    return undef unless scalar @fields;
+    return undef if scalar @fields == 1 and !defined $fields[0];
+    my $rowhash;
+    @{$rowhash}{@$col_names} = @fields;
+    return ( $rowhash );
+}
+sub get_undeleted_record {
+    my $self = shift;
+    my $rec;
+    my $found=0;
+    return $self->fetch_row if $self->parser_type eq 'XML';
+    while (!$found) {
+        my $test = $rec    = $self->{storage}->file2str($self->{parser});
+        return  if !defined $rec;
+        next if $self->{storage}->is_deleted($self->{parser});
+        next if $self->{parser}->{skip_pattern} 
+            and $rec =~ $self->{parser}->{skip_pattern};
+        last;
+    }
+    return $rec;
+#    return $rec if ref $rec eq 'ARRAY';
+#    return unless $rec;
+#    my @fields = $self->{parser}->read_fields($rec);
+#    return undef if scalar @fields == 1 and !defined $fields[0];
+#    return \@fields;
+}
+sub update_single_row {
+    my $self     = shift;
+    my $oldrow   = shift;
+    my $newvals  = shift;
+    my @colnames = @{ $self->col_names };
+    my @newrow;
+    my $requested_cols = [];
+    for my $i(0..$#colnames) {
+        push @$requested_cols, $colnames[$i] if defined $newvals->{$colnames[$i]};
+        $newrow[$i] = $newvals->{$colnames[$i]};
+        $newrow[$i] = $oldrow->{$colnames[$i]} unless defined $newrow[$i];
+    }
+    unshift @newrow, $requested_cols;
+    $self->{storage}->seek(0,2);
+    $self->push_row( @newrow );
+    return \@newrow;
+}
+sub update_multiple_rows {
+    my $self   = shift;
+    my $key    = shift;
+    my $values = shift;
+    $self->seek_first_record;
+    my @rows_to_update;
+    while (my $row = $self->fetchrow_hashref) {
+        next unless $self->match($row,$key);
+        $self->{parser}->{has_update_function}
+            ? $self->update_single_row($row,$values)
+            : $self->delete_single_row();
+        $self->{parser}->{has_update_function}
+            ? push @rows_to_update,1
+            : push @rows_to_update,$row;
+    }
+    if (!$self->{parser}->{has_update_function}) {
+        for (@rows_to_update) {
+           $self->update_single_row($_,$values);
+	 }
+    }
+    return scalar @rows_to_update;
+}
+sub match {
+    my($self,$row,$key) = @_;
+    if ( ref $key ne 'HASH') {
+        return 0 if !$row->{$self->key_col}
+                 or  $row->{$self->key_col} ne $key;
+        return 1;
+    }
+    my $found = 0;
+    while (my($col,$re)=each %$key) {
+        next unless defined $row->{$col} and is_matched($row->{$col},$re);
+        $found++;
+    }
+    return 1 if $found == scalar keys %$key;
+}
+sub is_matched {
+    my($str,$re)=@_;
+    if (ref $re eq 'Regexp') {
+        return $str =~ /$re/ ? 1 : 0;
+    }
+    my($op,$val);
+    
+    if ( $re and $re =~/^(\S*)\s+(.*)/ ) {
+        $op  = $1;
+        $val = $2;
+    }
+    elsif ($re) {
+        return $str =~ /$re/ ? 1 : 0;
+    }
+    else {
+        return $str eq '' ? 1 : 0;
+    }
+    my $numop = '< > == != <= >=';
+    my $chrop = 'lt gt eq ne le ge';
+    if (!($numop =~ /$op/) and !($chrop =~ /$op/)) {
+        return $str =~ /$re/ ? 1 : 0;
+    }
+    if ($op eq '<' ) { return $str <  $val; }
+    if ($op eq '>' ) { return $str >  $val; }
+    if ($op eq '==') { return $str == $val; }
+    if ($op eq '!=') { return $str != $val; }
+    if ($op eq '<=') { return $str <= $val; }
+    if ($op eq '>=') { return $str >= $val; }
+    if ($op eq 'lt') { return $str lt $val; }
+    if ($op eq 'gt') { return $str gt $val; }
+    if ($op eq 'eq') { return $str eq $val; }
+    if ($op eq 'ne') { return $str ne $val; }
+    if ($op eq 'le') { return $str le $val; }
+    if ($op eq 'ge') { return $str ge $val; }
+}
+sub delete_single_row {
+    my $self = shift;
+#    my $curpos = $self->{storage}->get_pos;
+    $self->{storage}->delete_record($self->{parser});
+#    $self->{storage}->go_pos($curpos);
+    $self->{needs_packing}++;
+}
+sub delete_multiple_rows {
+    my $self   = shift;
+    my $key    = shift;
+    $self->seek_first_record;
+    my $rows_deleted =0;
+    while (my $row = $self->fetchrow_hashref) {
+        next unless $self->match($row,$key);
+        $self->delete_single_row;
+        $rows_deleted++;
+    }
+    return $rows_deleted;
+}
+
+sub adNames { @{ shift->{__colnames}} }
+
+sub adDump {
+    my $table = shift;
+    my $pat   = shift;
+    die "No table defined" unless $table;
+    my $ad = tied(%$table)->{ad};
+    my @cols = @{ $ad->col_names };
+    print "<",join(":", @cols), ">\n";
+    while (my $row = each %$table) {
+        my @row  = map {defined $row->{$_} ? $row->{$_} : ''} @cols;
+        for (@row) { print "[$_]"; }
+        print  "\n";
+    }
+}
+
+sub adRows {
+    my $thash = shift;
+    my %keys  = @_;
+    my $obj   = tied(%$thash);
+    return $obj->adRows(\%keys);
+}
+sub adColumn {
+    my $thash  = shift;
+    my $column = shift;
+    my $flags = shift;
+    my $obj    = tied(%$thash);
+    return $obj->adColumn($column, $flags);
+}
+sub adArray {
+    my($format,$data)=@_;
+    my $t = adTie( $format, $data );
+    my $t1 = tied(%$t);
+    my $ad = $t1->{ad};
+    my $arrayref = $ad->{storage}->{records};
+    unshift @$arrayref, $ad->{storage}->{col_names};
+    return $arrayref;
+}
+##################################################################
+# END OF TIEDHASH STUFF
+##################################################################
+sub parser_type {
+    my $type = ref shift->{parser};
+    $type =~ s/AnyData::Format::(.*)/$1/;
+    return $type;
+}
+sub zpack {
+    my $self = shift;
+    return if $self->{storage}->{no_pack};
+    return if (ref $self->{storage} ) !~ /File$/;
+
+#    return unless $self->{needs_packing};
+#    $self->{needs_packing} = 0;
+    return unless scalar(keys %{ $self->{storage}->{deleted} } );
+    $self->{needs_packing} = 0;
+    #    my @callA = caller 2;
+    #    my @callB = caller 3;
+    #    return if $callA[3] =~ /DBD/;
+    #    return if $callB[3] and $callB[3] =~ /SQL::Statement/;
+    #    return if $self->{parser}->{export_on_close};
+    #print "PACKING";
+    my $bak_file = $self->{storage}->get_file_name . '.bak';
+    my $bak = adTable( 'Text', $bak_file, 'o' );
+    my $bak_fh = $bak->{storage}->get_file_handle;
+    my $fh     = $self->{storage}->get_file_handle;
+    die "Can't pack to backup $!" unless $fh and $bak_fh;
+    # $self->seek_first_record;
+    $fh->seek(0,0) || die $!;
+    #$bak_fh->seek(0,0) || die $!;
+#    while (my $line = $self->get_record) {
+#        next if $self->is_deleted($line);
+    while (my $line = $self->get_undeleted_record) {
+        my $tmpstr = $bak->{parser}->write_fields($line)
+                   . $self->{parser}->{record_sep};
+        $bak_fh->write($tmpstr,length $tmpstr);
+    }
+    $fh->seek(0,0);
+    $fh->truncate(0) || die $!;
+    $bak->seek_first_record;
+    while (<$bak_fh>) {
+        $fh->write($_,length $_);
+    }
+    $fh->close;
+    $bak_fh->close;
+    $self->{doing_pack} = 0;
+    undef $self->{storage}->{deleted};
+}
+
+##########################################################
+#  FUNCTION CALL INTERFACE
+##########################################################
+sub adTie {
+    my($format,$file,$read_mode,$flags)=@_;
+    my $data;
+    if (ref $file eq 'ARRAY' && !$read_mode ) { $read_mode = 'u'; }
+    # ARRAY only {data=>[]};
+    if (scalar @_ == 1){
+        $read_mode = 'o';
+        tie %$data,
+            'AnyData::Storage::TiedHash',
+            adTable($format),
+            $read_mode;
+        return $data;
+    }
+    tie %$data,
+        'AnyData::Storage::TiedHash',
+        adTable($format,$file,$read_mode,undef,$flags),
+        $read_mode;
+    return $data;
+}
+sub adErr {
+    my $hash = shift;
+    my $t = tied(%$hash);
+    my $errstr = $t->{ad}->{parser}->{errstr}
+        || $t->{ad}->{storage}->{errstr};
+    print $errstr if $errstr;
+    return $errstr;
+}
+sub adExport {
+    my $tiedhash  = shift;
+    my($tformat,$tfile,$tflags)=@_;
+    my $ad = tied(%$tiedhash)->{ad};
+    my $sformat = ref $ad->{parser};
+    $sformat =~ s/AnyData::Format:://;
+    $tformat ||= $sformat;
+    if ($tformat eq $sformat and $tformat eq 'XML') {
+      return $ad->{parser}->export($ad->{storage},$tfile,$tflags);
+    }
+    return adConvert('adHash',$ad,$tformat,$tfile,undef,$tflags);
+}
+sub adConvert {
+    my( $source_format, $source_data,
+        $target_format,$target_file_name,
+        $source_flags,$target_flags    )=@_;
+
+    my $target_type = 'STRING';
+       $target_type = 'FILE'  if defined $target_file_name;
+       $target_type = 'ARRAY' if $target_format eq 'ARRAY';
+
+    my $data_type = 'AD-OBJECT';
+       $data_type = 'ARRAY'  if  ref $source_data eq 'ARRAY'
+                            and  ref $source_data->[0] eq 'ARRAY';
+
+    # INIT SOURCE OBJECT
+    my $source_ad;
+    if ($source_format eq 'adHash') {
+        $source_ad = $source_data;
+        undef $source_data;
+    } 
+    else {
+        $source_format = 'CSV' if $source_format =~ /ARRAY/i;
+        $source_ad = adTable(
+             $source_format,$source_data,'r',undef,$source_flags
+        );
+    }
+
+    # GET COLUMN NAMES
+    my @cols;
+    if ( $data_type eq 'ARRAY') {
+        @cols = @{ shift @{ $source_data  } };
+    }
+    else {
+        @cols = @{ $source_ad->col_names };
+    }
+
+
+    # insert storable here
+    if ('XML HTMLtable' =~ /$target_format/) {
+        $target_flags->{col_names} = join ',', at cols;
+        my $target_ad = adTable(
+            $target_format,$target_file_name,'o',undef,$target_flags
+        );
+        if ($data_type eq 'ARRAY' ) {
+             for my $row(@$source_data) {
+                 my @fields=$source_ad->str2ary($row);
+                 $target_ad->push_row( $source_ad->str2ary(\@fields) );
+             }
+             unshift @$source_data, \@cols;
+             return $target_ad->export($target_file_name);
+        }
+        $source_ad->seek_first_record;
+        while (my $row = $source_ad->get_undeleted_record) {
+            $target_ad->push_row( $source_ad->str2ary($row) );
+        }
+        return $target_ad->export($target_file_name);
+    }
+
+    my($target_ad,$fh);
+    ### INIT TARGET OBJECT
+    if ($target_type eq 'FILE') {
+        $target_ad = adTable(
+            $target_format,$target_file_name,'c',undef,$target_flags
+        );
+        $fh = $target_ad->{storage}->get_file_handle;
+    }
+    elsif ($target_type eq 'STRING') {
+        $target_ad = AnyData->new( $target_format,$target_flags);
+    }
+
+    my($str,$aryref);
+    ### GET COLUMN NAMES
+    if ( !$target_ad->{parser}->{no_col_print} ) {
+        if ($target_type eq 'ARRAY') {
+            push @$aryref, \@cols;
+        }
+        else {
+        $str = $target_ad->{parser}->write_fields(@cols);
+        $str =~ s/ /,/g if $target_format eq 'Fixed';
+        if ($target_type eq 'FILE') {
+            $fh->write($str,length $str);
+	}
+        if ($target_type eq 'STRING') {
+            $str = $target_ad->{parser}->write_fields(@cols);
+	}
+	}
+    }
+
+    # GET DATA
+    if ($data_type eq 'ARRAY') {
+      for my $row(@$source_data) {
+        my @fields = $source_ad->str2ary($row);
+        my $tmpstr = $target_ad->{parser}->write_fields(@fields);
+        # print $tmpstr if $check;
+        $fh->write($tmpstr,length $tmpstr) if $target_type eq 'FILE';
+        $str .=  $tmpstr if $target_type eq 'STRING';
+      }
+      unshift @$source_data, \@cols;
+      return $str if $target_format ne 'ARRAY';
+      return $aryref;
+    }
+    $source_ad->seek_first_record; # unless $source_format eq 'XML';
+    while (my $row = $source_ad->get_undeleted_record) {
+        if ($target_format eq 'ARRAY') {
+            push @$aryref,$row if $target_format eq 'ARRAY';
+            next;
+        }
+        my @fields = $source_ad->str2ary($row);
+        my $tmpstr = $target_ad->{parser}->write_fields(@fields);
+        $str .= $target_type eq 'FILE'
+           ? $fh->write($tmpstr,length $tmpstr)
+           : $tmpstr;
+    }
+    return $str if $target_format ne 'ARRAY';
+    return $aryref;
+}
+
+#    if ('Storable' =~ /$target_format/) {
+#        $target_flags->{col_names} = join ',', at cols;
+#        $target_ad = adTable(
+#            $target_format,$target_file_name,'c',undef,$target_flags
+#        );
+#        if (ref $source_data && !$data) {
+#            for my $row(@$source_data) {
+#                push @$data,$row;
+#            }
+#        }
+#        elsif (!$data) {
+#            $source_ad->seek_first_record;
+#            while (my $row = $source_ad->fetch_row) {
+#                push @$data, $row;
+#           }
+#	}
+#        unshift @$data, \@cols;
+#        return $target_ad->{parser}->export($data,$target_file_name);
+#  }
+
+sub str2ary {
+    my($ad,$row) = @_;
+    return @$row if ref $row eq 'ARRAY';
+    return $ad->{parser}->read_fields($row);
+}
+sub ad_string {
+    my($formatref, at fields) = @_;
+    my($format,$flags) = split_params($formatref);
+# &dump($formatref); print "<$format>"; &dump($flags) if $flags;
+    #$formatref =~ s/(.*)/$1/;
+    my $ad = AnyData->new( $format, $flags );
+    return $ad->{parser}->write_fields(@fields);
+#    return $ad->write_fields(@fields);
+}
+
+sub ad_fields {
+    my($formatref,$str,$flags) = @_;
+#    my($format,$flags) = split_params($formatref);
+#    my $ad = AnyData::new( $format, $flags );
+    my $ad = AnyData->new( $formatref, $flags );
+    return $ad->{parser}->read_fields($str);
+}
+
+sub ad_convert_str {
+    my($source_formatref,$target_formatref,$str) = @_;
+    my($source_format,$source_flags) = split_params($source_formatref);
+    my($target_format,$target_flags) = split_params($target_formatref);
+    my $source_ad = AnyData->new( $source_format,$source_flags);
+    my $target_ad = AnyData->new( $target_format,$target_flags);
+    my @fields = $source_ad->read_fields($str);
+    return $target_ad->write_fields( @fields );
+}
+
+#########################################################
+# UTILITY METHODS
+#########################################################
+#
+# For all methods that have $format as a parameter,
+# $format can be either a string name of a format e.g. 'CSV'
+# or a hashref of the format and flags for that format e.g.
+# { format => 'FixedWidth', pattern=>'A1 A3 A2' }
+#
+# given this parameter, this method returns $format and $flags
+# setting $flags to {} if none are given
+#
+sub split_params {
+    my $source_formatref = shift;
+    my $source_flags = {};
+    my $source_format  = $source_formatref;
+    if (ref $source_formatref eq 'HASH') {
+      while (my($k,$v)=each %$source_formatref) {
+           ($source_format,$source_flags) = ($k,$v);
+      }
+    }
+    #use Data::Dumper;
+    return( $source_format, $source_flags);
+}
+sub dump {
+    my $var = shift;
+    my $name = ref($var);
+    #use Data::Dumper;
+    $Data::Dumper::Indent = 1;
+    $Data::Dumper::Useqq  = 0;
+    print Data::Dumper->new([$var],[$name])->Dump();
+}
+
+###########################################################################
+# START OF DOCUMENTATION
+###########################################################################
+
+=pod
+
+=head1 NAME
+
+AnyData - (DEPRECATED) easy access to data in many formats
+
+=head1 SYNOPSIS
+
+ use AnyData;
+ my $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
+
+=head1 DESCRIPTION
+
+The rather wacky idea behind this module and its sister module
+DBD::AnyData is that any data, regardless of source or format should
+be accessible and modifiable with the same simple set of methods.
+This module provides a multidimensional 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 flat files (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.
+
+=head1 PREREQUISITES
+
+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.
+
+=head1 USAGE
+
+The AnyData module imports eight methods (functions):
+
+=for test ignore
+
+  adTie()     -- create a new table or open an existing table
+  adExport()  -- save an existing table in a specified format
+  adConvert() -- convert data in one format into another format
+  adFormats() -- list available formats
+  adNames()   -- get the column names of a table
+  adRows()    -- get the number of rows in a table or query
+  adDump()    -- display the data formatted as an array of rows
+  adColumn()  -- group values in a single column
+
+The adTie() command returns a special tied hash.  The tied hash can
+then be used to access and/or modify data.  See below for details
+
+With the exception of the XML, HTMLtable, and ARRAY formats, the
+adTie() command saves all modifications of the data directly to file
+as they are made.  With XML and HTMLtable, you must make your
+modifications in memory and then explicitly save them to file with
+adExport().
+
+=head2 adTie()
+
+ my $table = adTie( $format, $data, $open_mode, $flags );
+
+The adTie() command creates a reference to a multidimensional tied hash. In its simplest form, it simply reads a file in a specified format into the tied hash:
+
+ my $table = adTie( $format, $file );
+
+$format is the name of any supported format 'CSV','Fixed','Passwd', etc.
+$file is the name of a relative or absolute path to a local file
+
+e.g. 
+     my $table = adTie( 'CSV', '/usr/me/myfile.csv' );
+
+this creates a tied hash called $table by reading data in the
+CSV (comma separated values) format from the file 'myfile.csv'.
+
+The hash reference resulting from adTie() can be accessed and modified as follows:
+
+ use AnyData;
+ my $table = adTie( $format, $file );
+ $table->{$key}->{$column};                       # select a value
+ $table->{$key} = {$col1=>$val1,$col2=>$val2...}; # update a row
+ delete $table->{$key};                           # delete a row
+ while(my $row = each %$table) {                  # loop through rows
+   print $row->{$col1} if $row->{$col2} ne 'baz';
+ }
+
+The thing returned by adTie ($table in the example) is not an object,
+it is a reference to a tied hash. This means that hash operations
+such as exists, values, keys, may be used, keeping in mind that this
+is a *reference* to a tied hash so the syntax would be
+
+    for( keys %$table ) {...}
+    for( values %$table ) {...}
+
+Also keep in mind that if the table is really large, you probably do
+not want to use keys and values because they create arrays in memory
+containing data from every row in the table.  Instead use 'each' as
+shown above since that cycles through the file one record at a time
+and never puts the entire table into memory.
+
+It is also possible to use more advanced searching on the hash, see "Multiple Row Operations" below.
+
+In addition to the simple adTie($format,$file), there are other ways to specify additional information in the adTie() command.  The full syntax is:
+
+ my $table = adTie( $format, $data, $open_mode, $flags );
+
+ The $data parameter allows you to read data from remote files accessible by
+ http or ftp, see "Using Remote Files" below.  It also allows you to treat
+ strings and arrays as data sources without needing a file at all, see
+ "Working with Strings and Arrays" below.
+
+The optional $mode parameter defaults to 'r' if none is supplied or must be
+one of
+
+ 'r' read      # read only access
+ 'u' update    # read/write access
+ 'c' create    # create a new file unless it already exists
+ 'o' overwrite # create a new file, overwriting any that already exist
+
+The $flags parameter allows you to specify additional information such as column names.  See the sections in "Further Details" below.
+
+With the exception of the XML, HTMLtable, and ARRAY formats, the
+adTie() command saves all modifications of the data directly to file
+as they are made.  With XML and HTMLtable, you must make your
+modifications in memory and then explicitly save them to file with
+adExport().
+
+=head2 adConvert()
+
+ adConvert( $format1, $data1, $format2, $file2, $flags1, $flags2 );
+
+ or
+
+ print adConvert( $format1, $data1, $format2, undef, $flags1, $flags2 );
+
+ or
+
+ my $aryref = adConvert( $format1, $data1, 'ARRAY', undef, $flags1 );
+
+ This method converts data in any supported format into any other supported
+ format.  The resulting data may either be saved to a file (if $file2 is
+ supplied as a parameter) or sent back as  a string to e.g. print the data
+ to the screen in the new format (if no $file2 is supplied), or sent back
+ as an array reference if $format2 is 'ARRAY'.
+
+ Some examples:
+
+   # convert a CSV file into an XML file
+   #
+   adConvert('CSV','foo.csv','XML','foo.xml');
+
+   # convert a CSV file into an HTML table and print it to the screen
+   #
+   print adConvert('CSV','foo.csv','HTMLtable');
+
+   # convert an XML string into a CSV file
+   #
+   adConvert('XML', ["<x><motto id='perl'>TIMTOWTDI</motto></x>"],
+             'CSV','foo.csv'
+            );
+
+   # convert an array reference into an XML file
+   #
+   adConvert('ARRAY', [['id','motto'],['perl','TIMTOWTDI']],
+             'XML','foo.xml'
+            );
+
+   # convert an XML file into an array reference
+   #
+   my $aryref = adConvert('XML','foo.xml','ARRAY');
+
+ See section below "Using strings and arrays" for details.
+
+=head2 adExport()
+
+ adExport( $table, $format, $file, $flags );
+
+ or
+
+ print adExport( $table, $format );
+
+ or
+
+ my $aryref = adExport( $table, 'ARRAY' );
+
+ This method converts an existing tied hash into another format and/or
+ saves the tied hash as a file in the specified format.
+
+ Some examples:
+
+   all assume a previous call to my $table= adTie(...);
+
+   # export table to an XML file
+   #
+   adExport($table','XML','foo.xml');
+
+   # export table to an HTML string and print it to the screen
+   #
+   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::Parser) and you do not have the additional modules installed, the format will not work even if listed by this command.  Otherwise, all formats should work as described in this documentation.
+
+=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.
+
+ Included below are only some of the more important details of the
+ specific parsers.
+
+=over
+
+=item Fixed Format
+
+When using the Fixed format for fixed length records you
+must always specify a pattern indicating the lengths of the fields.
+This should be a string as would be passed to the unpack() function
+to unpack the records in your Fixed length definition:
+
+ my $t = adTie( 'Fixed', $file, 'r', {pattern=>'A3 A7 A9'} );
+
+If you want the column names to appear on the first line of a Fixed
+file, they should be in comma-separated format, not in Fixed format.
+This is different from other formats which use their own format to
+display the column names on the first line.  This is necessary because
+the name of the column might be longer than the length of the column.
+
+=item XML Format
+
+ The XML format does not allow you to specify column names as a flag,
+ rather you specify a "record_tag" and the column names are determined
+ from the contents of the tag.  If no record_tag is specified, the
+ record tag will be assumed to be the first child of the root of the
+ XML tree.  That child and its structure will be determined from the
+ DTD if there is one, or from the first occurring record if there is
+ no DTD.
+
+For simple XML, no flags are necessary:
+
+ <table>
+    <row row_id="1"><name>Joe</name><location>Seattle</location></row>
+    <row row_id="2"><name>Sue</name><location>Portland</location></row>
+ </table>
+
+The record_tag will default to the first child, namely "row".  The column
+names will be generated from the attributes of the record tag and all of
+the tags included under the record tag, so the column names in this
+example will be "row_id","name","location".
+
+If the record_tag is not the first child, you will need to specify it.  For example:
+
+ <db>
+   <table table_id="1">
+     <row row_id="1"><name>Joe</name><location>Seattle</location></row>
+     <row row_id="2"><name>Sue</name><location>Portland</location></row>
+   </table>
+   <table table_id="2">
+     <row row_id="1"><name>Bob</name><location>Boise</location></row>
+     <row row_id="2"><name>Bev</name><location>Billings</location></row>
+   </table>
+ </db>
+
+In this case you will need to specify "row" as the record_tag since it is not the first child of the tree.  The column names will be generated from the attributes of row's parent (if the parent is not the root), from row's attributes
+and sub tags, i.e. "table_id","row_id","name","location".
+
+When exporting XML, you can specify a DTD to control the output.  For example, if you import a table from CSV or from an Array, you can output as XML and specify which of the columns become tags and which become attributes and also specify the nesting of the tags in your DTD.
+
+The XML format parser is built on top of Michel Rodriguez's excellent XML::Twig which is itself based on XML::Parser.  Parameters to either of those modules may be passed in the flags for adTie() and the other commands including the "prettyPrint" flag to specify how the output XML is displayed and things like ProtocolEncoding.  ProtocolEncoding defaults to 'ISO-8859-1', all other flags keep the defaults of XML::Twig and XML::Parser.  See the documentation of those modules for details;
+
+ CAUTION: Unlike other formats, the XML format does not save changes to
+ the file as they are entered, but only saves the changes when you explicitly
+ request them to be saved with the adExport() command.
+
+=item HTMLtable Format
+
+ This format is based on Matt Sisk's excelletn HTML::TableExtract.
+
+ It can be used to read an existing table from an html page, or to
+ create a new HTML table from any data source.
+
+ You may control which table in an HTML page is used with the column_names,
+ depth and count flags.
+
+ If a column_names flag is passed, the first table that contains those names
+ as the cells in a row will be selected.
+
+ If depth and or count parameters are passed, it will look for tables as
+ specified in the HTML::TableExtract documentation.
+
+ If none of column_names, depth, or count flags are passed, the first table
+ encountered in the file will be the table selected and its first row will
+ be used to determine the column names for the table.
+
+ When exporting to an HTMLtable, you may pass flags to specify properties
+ of the whole table (table_flags), the top row containing the column names
+ (top_row_flags), and the data rows (data_row_flags).  These flags follow
+ the syntax of CGI.pm table constructors, e.g.:
+
+ print adExport( $table, 'HTMLtable', {
+     table_flags    => {Border=>3,bgColor=>'blue'};
+     top_row_flags  => {bgColor=>'red'};
+     data_row_flags => {valign='top'};
+ });
+
+ The table_flags will default to {Border=>1,bgColor=>'white'} if none
+ are specified.
+
+ The top_row_flags will default to {bgColor=>'#c0c0c0'} if none are
+ specified;
+
+ The data_row_flags will be empty if none are specified.
+
+ In other words, if no flags are specified the table will print out with
+ a border of 1, the column headings in gray, and the data rows in white.
+
+ CAUTION: This module will *not* preserve anything in the html file except
+ the selected table so if your file contains more than the selected table,
+ you will want to use adTie() to read the table and then adExport() to write
+ the table to a different file.  When using the HTMLtable format, this is the
+ only way to preserve changes to the data, the adTie() command will *not*
+ write to a file.
+
+=back
+
+=head2 Multiple Row Operations
+
+The AnyData hash returned by adTie() may use either single values as keys, or a reference to a hash of comparisons as a key.  If the key to the hash is a single value, the hash operates on a single row but if the key to the hash is itself a hash reference, the hash operates on a group of rows.
+
+ my $num_deleted = delete $table->{Sue};
+
+This example deletes a single row where the key column has the value 'Sue'.  If multiple rows have the value 'Sue' in that column, only the first is deleted.  It uses a simple string as a key, therefore it operates on only a single row.
+
+ my $num_deleted = delete $table->{ {name=>'Sue'} };
+
+This example deletes all rows where the column 'name' is equal to 'Sue'.  It uses a hashref as a key and therefore operates on multiple rows.
+
+The hashref used in this example is a single column comparison but the hashref could also include multiple column comparisons.  This deletes all rows where the the values listed for the country, gender, and age columns are equal to those specified:
+
+  my $num_deleted = delete $table->{{ country => 'us',
+                                       gender => 'm',
+                                          age => '25'
+                                   }}
+
+
+In addition to simple strings, the values may be specified as regular expressions or as numeric or alphabetic comparisons.  This will delete all North American males under the age of 25:
+
+  my $num_deleted = delete $table->{{ country => qr/mx|us|ca/,
+                                      gender  => 'm',
+                                      age     => '< 25'
+                                   }}
+
+If numeric or alphabetic comparisons are used, they should be a string with the comparison operator separated from the value by a space, e.g. '> 4' or 'lt b'.
+
+This kind of search hashref can be used not only to delete multiple rows, but also to update rows.  In fact you *must* use a hashref key in order to update your table.  Updating is the only operation that can not be done with a single string key.
+
+The search hashref can be used with a select statement, in which case it returns a reference to an array of rows matching the criteria:
+
+ my $male_players = $table->{{gender=>'m'}};
+ for my $player( @$male_players ) { print $player->{name},"\n" }
+
+This should be used with caution with a large table since it gathers all of the selected rows into an array in memory.  Again, 'each' is a much better way for large tables.  This accomplishes the same thing as the example above, but without ever pulling more than a row into memory at a time:
+
+ while( my $row= each %$table ) {
+   print $row->{name}, "\n" if $row->{gender}=>'m';
+ }
+
+Search criteria for multiple rows can also be used with the adRows() function:
+
+  my $num_of_women = adRows( $table, gender => 'w' );
+
+That does *not* pull the entire table into memory, it counts the rows a record at a time.
+
+=head2 Using Remote Files
+
+If the first file parameter of adTie() or adConvert() begins with "http://" or "ftp://", the file is treated as a remote URL and the LWP module is called behind the scenes to fetch the file.  If the files are in an area that requires authentication, that may be supplied in the $flags parameter.
+
+For example:
+
+  # read a remote file and access it via a tied hash
+  #
+  my $table = adTie( 'XML', 'http://www.foo.edu/bar.xml' );
+
+  # same with username/password
+  #
+  my $table = ( 'XML', 'ftp://www.foo.edu/pub/bar.xml', 'r'
+                { user => 'me', pass => 'x7dy4'
+              );
+
+  # read a remote file, convert it to an HTML table, and print it
+  #
+  print adConvert( 'XML', 'ftp://www.foo.edu/pub/bar.xml', 'HTMLtable' );
+
+=head2 Using Strings and Arrays
+
+Strings and arrays may be used as either the source of data input or as the target of data output.  Strings should be passed as the only element of an array reference (in other words, inside square brackets).  Arrays should be a reference to an array whose first element is a reference to an array of column names and whose succeeding elements are references to arrays of row values.
+
+For example:
+
+  my $table = adTie( 'XML', ["<x><motto id='perl'>TIMTOWTDI</motto></x>"] );
+
+  This uses the XML format to parse the supplied string and returns a tied
+  hash to the resulting table.
+
+
+  my $table = adTie( 'ARRAY', [['id','motto'],['perl','TIMTOWTDI']] );
+
+  This uses the column names "id" and "motto" and the supplied row values
+  and returns a tied hash to the resulting table.
+
+It is also possible to use an empty array to create a new empty tied hash in any format, for example:
+
+  my $table = adTie('XML',[],'c');
+
+  creates a new empty tied hash;
+
+See adConvert() and adExport() for further examples of using strings and arrays.
+
+=head2 Ties, Flocks, I/O, and Atomicity
+
+AnyData provides flocking which works under the limitations of flock -- that it only works if other processes accessing the files are also using flock and only on platforms that support flock.  See the flock() man page for details.
+
+Here is what the user supplied open modes actually do:
+
+ r = read only  (LOCK_SH)  O_RDONLY
+ u = update     (LOCK_EX)  O_RDWR
+ c = create     (LOCK_EX)  O_CREAT | O_RDWR | O_EXCL
+ o = overwrite  (LOCK_EX)  O_CREAT | O_RDWR | O_TRUNC
+
+When you use something like "my $table = adTie(...)", it opens
+the file with a lock and leaves the file and lock open until
+1) the hash variable ($table) goes out of scope or 2) the
+hash is undefined (e.g. "undef $table") or 3) the hash is
+re-assigned to another tie.  In all cases the file is closed
+and the lock released.
+
+If adTie is called without creating a tied hash variable, the file
+is closed and the lock released immediately after the call to adTie.
+
+ For example:  print adTie('XML','foo.xml')->{main_office}->{phone}.
+
+ That obtains a shared lock, opens the file, retrieves the one value
+ requested, closes the file and releases the lock.
+
+These two examples accomplish the same thing but the first example
+opens the file once, does all of the deletions, keeping the exclusive
+lock in place until they are all done, then closes the
+file.  The second example opens and closes the file three times,
+once for each deletion and releases the exclusive lock between each
+deletion:
+
+ 1. my $t = adTie('Pipe','games.db','u');
+    delete $t->{"user$_"} for (0..3);
+    undef $t; # closes file and releases lock
+
+ 2. delete adTie('Pipe','games.db','u')->{"user$_"} for (0..3);
+    # no undef needed since no hash variable created
+
+=head2 Deletions and Packing
+
+In order to save time and to prevent having to do writes anywhere except at the end of the file, deletions and updates are *not* done at the time of issuing a delete command.  Rather when the user does a delete, the position of the deleted record is stored in a hash and when the file is saved to disk, the deletions are only then physically removed by packing the entire database.  Updates are done by inserting the new record at the end of the file and marking the old record for deletion.  [...]
+
+=head1 MORE HELP
+
+See the README file and the test.pl included with the module
+for further examples.
+
+See the AnyData/Format/*.pm PODs for further details of specific
+formats.
+
+For further support, please use comp.lang.perl.modules
+
+=head1 ACKNOWLEDGEMENTS
+
+Special thanks to Andy Duncan, Tom Lowery, Randal Schwartz, Michel Rodriguez, Jochen Wiedmann, Tim Bunce, Alligator Descartes, Mathew Persico, Chris Nandor, Malcom Cook and to many others on the DBI mailing lists and the clp* newsgroups.
+
+=head1 AUTHOR & COPYRIGHT
+
+ Jeff Zucker <jeff at vpservices.com>
+
+ This module is copyright (c), 2000 by Jeff Zucker.
+ Some changes (c) 2012 Sven Dowideit L<mailto:SvenDowideit at fosiki.com>
+ It may be freely distributed under the same terms as Perl itself.
+
+=cut
+
+################################
+# END OF AnyData
+################################
+1;
diff --git a/AnyData/Format/Base.pm b/lib/AnyData/Format/Base.pm
similarity index 100%
rename from AnyData/Format/Base.pm
rename to lib/AnyData/Format/Base.pm
diff --git a/AnyData/Format/CSV.pm b/lib/AnyData/Format/CSV.pm
similarity index 99%
rename from AnyData/Format/CSV.pm
rename to lib/AnyData/Format/CSV.pm
index cb9c0cb..f6d1365 100644
--- a/AnyData/Format/CSV.pm
+++ b/lib/AnyData/Format/CSV.pm
@@ -57,7 +57,7 @@ use AnyData::Format::Base;
 use vars qw( @ISA $VERSION);
 @AnyData::Format::CSV::ISA = qw( AnyData::Format::Base );
 
-$VERSION = '0.05';
+$VERSION = '0.12';
 
 sub new {
     my $class = shift;
diff --git a/AnyData/Format/FileSys.pm b/lib/AnyData/Format/FileSys.pm
similarity index 100%
rename from AnyData/Format/FileSys.pm
rename to lib/AnyData/Format/FileSys.pm
diff --git a/AnyData/Format/Fixed.pm b/lib/AnyData/Format/Fixed.pm
similarity index 99%
rename from AnyData/Format/Fixed.pm
rename to lib/AnyData/Format/Fixed.pm
index efa8d66..50eeee6 100644
--- a/AnyData/Format/Fixed.pm
+++ b/lib/AnyData/Format/Fixed.pm
@@ -49,7 +49,7 @@ use AnyData::Format::Base;
 use vars qw( @ISA $VERSION);
 @AnyData::Format::Fixed::ISA = qw( AnyData::Format::Base );
 
-$VERSION = '0.05';
+$VERSION = '0.12';
 
 sub read_fields {
     my $self = shift;
diff --git a/AnyData/Format/HTMLtable.pm b/lib/AnyData/Format/HTMLtable.pm
similarity index 99%
rename from AnyData/Format/HTMLtable.pm
rename to lib/AnyData/Format/HTMLtable.pm
index 0478382..5fcb9a6 100644
--- a/AnyData/Format/HTMLtable.pm
+++ b/lib/AnyData/Format/HTMLtable.pm
@@ -88,7 +88,7 @@ use AnyData::Storage::File;
 use vars qw( @ISA $VERSION);
 @AnyData::Format::HTMLtable::ISA = qw( AnyData::Format::Base );
 
-$VERSION = '0.05';
+$VERSION = '0.12';
 
 sub new {
     my $class = shift;
diff --git a/AnyData/Format/Ini.pm b/lib/AnyData/Format/Ini.pm
similarity index 99%
rename from AnyData/Format/Ini.pm
rename to lib/AnyData/Format/Ini.pm
index 25c0d45..f5e1927 100644
--- a/AnyData/Format/Ini.pm
+++ b/lib/AnyData/Format/Ini.pm
@@ -48,7 +48,7 @@ use warnings;
 use vars qw/@ISA $VERSION/;
 @ISA = qw(AnyData::Format::CSV);
 
-$VERSION = '0.05';
+$VERSION = '0.12';
 
 
 sub new {
diff --git a/AnyData/Format/Mp3.pm b/lib/AnyData/Format/Mp3.pm
similarity index 99%
rename from AnyData/Format/Mp3.pm
rename to lib/AnyData/Format/Mp3.pm
index 238f4f2..11e8322 100644
--- a/AnyData/Format/Mp3.pm
+++ b/lib/AnyData/Format/Mp3.pm
@@ -62,7 +62,7 @@ use AnyData::Storage::File;
 use vars qw( @ISA $VERSION);
 @AnyData::Format::Mp3::ISA = qw( AnyData::Format::Base );
 
-$VERSION = '0.05';
+$VERSION = '0.12';
 
 sub new {
     my $class = shift;
diff --git a/AnyData/Format/Paragraph.pm b/lib/AnyData/Format/Paragraph.pm
similarity index 99%
rename from AnyData/Format/Paragraph.pm
rename to lib/AnyData/Format/Paragraph.pm
index 216e3af..6d88b2a 100644
--- a/AnyData/Format/Paragraph.pm
+++ b/lib/AnyData/Format/Paragraph.pm
@@ -59,7 +59,7 @@ use AnyData::Format::CSV;
 use vars qw/@ISA $VERSION/;
 @ISA = qw(AnyData::Format::CSV);
 
-$VERSION = '0.05';
+$VERSION = '0.12';
 
 sub new {
     my $class = shift;
diff --git a/AnyData/Format/Passwd.pm b/lib/AnyData/Format/Passwd.pm
similarity index 98%
rename from AnyData/Format/Passwd.pm
rename to lib/AnyData/Format/Passwd.pm
index bcc0858..95723bb 100644
--- a/AnyData/Format/Passwd.pm
+++ b/lib/AnyData/Format/Passwd.pm
@@ -57,7 +57,7 @@ use AnyData::Format::CSV;
 use vars qw( @ISA $VERSION);
 @AnyData::Format::Passwd::ISA = qw( AnyData::Format::CSV );
 
-$VERSION = '0.05';
+$VERSION = '0.12';
 
 sub new {
     my $class = shift;
diff --git a/AnyData/Format/Pipe.pm b/lib/AnyData/Format/Pipe.pm
similarity index 98%
rename from AnyData/Format/Pipe.pm
rename to lib/AnyData/Format/Pipe.pm
index d52f1fa..775e4bd 100644
--- a/AnyData/Format/Pipe.pm
+++ b/lib/AnyData/Format/Pipe.pm
@@ -53,7 +53,7 @@ use AnyData::Format::CSV;
 use vars qw( @ISA $VERSION);
 @AnyData::Format::Pipe::ISA = qw( AnyData::Format::CSV );
 
-$VERSION = '0.05';
+$VERSION = '0.12';
 
 sub new {
     my $class = shift;
diff --git a/AnyData/Format/Tab.pm b/lib/AnyData/Format/Tab.pm
similarity index 99%
rename from AnyData/Format/Tab.pm
rename to lib/AnyData/Format/Tab.pm
index f5b0ca9..39d1c0f 100644
--- a/AnyData/Format/Tab.pm
+++ b/lib/AnyData/Format/Tab.pm
@@ -56,7 +56,7 @@ use AnyData::Format::CSV;
 use vars qw( @ISA $VERSION );
 @AnyData::Format::Tab::ISA = qw( AnyData::Format::CSV );
 
-$VERSION = '0.05';
+$VERSION = '0.12';
 
 sub new {
     my $class = shift;
diff --git a/AnyData/Format/Text.pm b/lib/AnyData/Format/Text.pm
similarity index 100%
rename from AnyData/Format/Text.pm
rename to lib/AnyData/Format/Text.pm
diff --git a/AnyData/Format/Weblog.pm b/lib/AnyData/Format/Weblog.pm
similarity index 99%
rename from AnyData/Format/Weblog.pm
rename to lib/AnyData/Format/Weblog.pm
index 4455be1..10facae 100644
--- a/AnyData/Format/Weblog.pm
+++ b/lib/AnyData/Format/Weblog.pm
@@ -68,7 +68,7 @@ use vars qw( @ISA $DEBUG $VERSION);
 @AnyData::Format::Weblog::ISA = qw( AnyData::Format::Base );
 $DEBUG                        = 0;
 
-$VERSION = '0.06';
+$VERSION = '0.12';
 
 sub new {
     my $class = shift;
diff --git a/AnyData/Format/XML.pm b/lib/AnyData/Format/XML.pm
similarity index 99%
rename from AnyData/Format/XML.pm
rename to lib/AnyData/Format/XML.pm
index 97a5181..bb83cbd 100644
--- a/AnyData/Format/XML.pm
+++ b/lib/AnyData/Format/XML.pm
@@ -13,7 +13,7 @@ use XML::Twig;
 use vars qw( @ISA  $DEBUG $VERSION);
 @AnyData::Format::XML::ISA = qw( AnyData::Format::Base );
 
-$VERSION = '0.05';
+$VERSION = '0.12';
 
 sub seek    { 1 }
 sub get_pos { 1 }
diff --git a/AnyData/Storage/File.pm b/lib/AnyData/Storage/File.pm
similarity index 100%
rename from AnyData/Storage/File.pm
rename to lib/AnyData/Storage/File.pm
diff --git a/AnyData/Storage/File.pod b/lib/AnyData/Storage/File.pod
similarity index 100%
rename from AnyData/Storage/File.pod
rename to lib/AnyData/Storage/File.pod
diff --git a/AnyData/Storage/FileSys.pm b/lib/AnyData/Storage/FileSys.pm
similarity index 100%
rename from AnyData/Storage/FileSys.pm
rename to lib/AnyData/Storage/FileSys.pm
diff --git a/AnyData/Storage/PassThru.pm b/lib/AnyData/Storage/PassThru.pm
similarity index 98%
rename from AnyData/Storage/PassThru.pm
rename to lib/AnyData/Storage/PassThru.pm
index a4d112c..ff1d218 100644
--- a/AnyData/Storage/PassThru.pm
+++ b/lib/AnyData/Storage/PassThru.pm
@@ -11,7 +11,7 @@ use strict;
 use warnings;
 use vars qw($VERSION @ISA);
 
-$VERSION = '0.07';
+$VERSION = '0.12';
 
 use AnyData::Storage::File;
 @ISA = qw( AnyData::Storage::File);
diff --git a/AnyData/Storage/RAM.pm b/lib/AnyData/Storage/RAM.pm
similarity index 99%
rename from AnyData/Storage/RAM.pm
rename to lib/AnyData/Storage/RAM.pm
index 1368088..ec1cd90 100644
--- a/AnyData/Storage/RAM.pm
+++ b/lib/AnyData/Storage/RAM.pm
@@ -12,7 +12,7 @@ use warnings;
 
 use vars qw($VERSION $DEBUG);
 
-$VERSION = '0.08';
+$VERSION = '0.12';
 
 $DEBUG   = 1;
 use Data::Dumper;
diff --git a/AnyData/Storage/TiedHash.pm b/lib/AnyData/Storage/TiedHash.pm
similarity index 100%
rename from AnyData/Storage/TiedHash.pm
rename to lib/AnyData/Storage/TiedHash.pm
diff --git a/t/htmltable.out b/t/htmltable.out
deleted file mode 100644
index 7447b9e..0000000
--- a/t/htmltable.out
+++ /dev/null
@@ -1 +0,0 @@
-<table>t/htmltable.out <tr bgcolor="#c0c0c0"><th>word</th> <th>number</th></tr> <tr><td>one</td> <td>1</td></tr> <tr><td>two</td> <td>2</td></tr> <tr><td>three</td> <td>3</td></tr> <tr><td>unknown</td></tr> <tr><td>unknowncomma</td> <td> </td></tr> <tr><td>zero</td> <td> </td></tr></table>
\ No newline at end of file
diff --git a/t/xml.out b/t/xml.out
deleted file mode 100644
index e69de29..0000000
diff --git a/xt/distribution.t b/xt/distribution.t
deleted file mode 100644
index 9c0bab9..0000000
--- a/xt/distribution.t
+++ /dev/null
@@ -1,17 +0,0 @@
-use Test::More;
-
-BEGIN {
-
-    eval { require Test::Distribution; };
-    if ($@) {
-        plan skip_all => 'Test::Distribution not installed';
-    }
-    else {
-
-        #TODO: work to fix these
-        import Test::Distribution
-          only => [qw/description/],
-          not  => [qw/use sig versions use prereq pod podcoverage/];
-    }
-}
-
diff --git a/xt/kwalitee.t b/xt/kwalitee.t
deleted file mode 100644
index 5015220..0000000
--- a/xt/kwalitee.t
+++ /dev/null
@@ -1,6 +0,0 @@
-## in a separate test file
-use Test::More;
-
-eval { require Test::Kwalitee; Test::Kwalitee->import() };
-
-plan( skip_all => 'Test::Kwalitee not installed; skipping' ) if $@;
diff --git a/xt/manifest.t b/xt/manifest.t
deleted file mode 100644
index cf89698..0000000
--- a/xt/manifest.t
+++ /dev/null
@@ -1,9 +0,0 @@
-#!perl -T
-
-use strict;
-use warnings;
-use Test::More;
-
-eval "use Test::CheckManifest 0.9";
-plan skip_all => "Test::CheckManifest 0.9 required" if $@;
-ok_manifest();
diff --git a/xt/pod-coverage.t b/xt/pod-coverage.t
deleted file mode 100644
index 36f9860..0000000
--- a/xt/pod-coverage.t
+++ /dev/null
@@ -1,22 +0,0 @@
-use strict;
-use warnings;
-use Test::More;
-
-plan skip_all =>
-  'AnyData is not yet updated for testing pod coverage to make sense';
-
-# Ensure a recent version of Test::Pod::Coverage
-my $min_tpc = 1.08;
-eval "use Test::Pod::Coverage $min_tpc";
-plan skip_all =>
-  "Test::Pod::Coverage $min_tpc required for testing POD coverage"
-  if $@;
-
-# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
-# but older versions don't recognize some common documentation styles
-my $min_pc = 0.18;
-eval "use Pod::Coverage $min_pc";
-plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
-  if $@;
-
-all_pod_coverage_ok();
diff --git a/xt/pod-snippets.t b/xt/pod-snippets.t
deleted file mode 100644
index 1cd53c4..0000000
--- a/xt/pod-snippets.t
+++ /dev/null
@@ -1,12 +0,0 @@
-use Test::More;
-plan skip_all => 'Need to do more work fixing pod code snippets';
-
-eval "use Test::Pod::Snippets";
-plan skip_all => "Test::Pod::Snippets required" if $@;
-
-my @modules = qw/ AnyData /;
-plan tests => 3;
-
-my $tps = Test::Pod::Snippets->new;
-
-$tps->runtest( module => $_, testgroup => 1 ) for @modules;
diff --git a/xt/pod.t b/xt/pod.t
deleted file mode 100644
index ee8b18a..0000000
--- a/xt/pod.t
+++ /dev/null
@@ -1,12 +0,0 @@
-#!perl -T
-
-use strict;
-use warnings;
-use Test::More;
-
-# Ensure a recent version of Test::Pod
-my $min_tp = 1.22;
-eval "use Test::Pod $min_tp";
-plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
-
-all_pod_files_ok();
diff --git a/xt/spelling.t b/xt/spelling.t
deleted file mode 100644
index be094dd..0000000
--- a/xt/spelling.t
+++ /dev/null
@@ -1,48 +0,0 @@
-## in a separate test file
-use Test::More;
-
-eval 'use Test::Spelling;';
-
-plan( skip_all => 'Test::Spelling not installed; skipping' ) if $@;
-add_stopwords(<DATA>);
-all_pod_files_spelling_ok();
-
-__END__
-AnyData
-Zucker
-CSV
-csv
-DBI
-DTD
-SQL
-Dowideit
-SvenDowideit
-tiedhash
-submodule
-username
-mpeg
-CGI
-HTMLtable
-Ini
-NCSA
-Fieldnames
-weblog
-logfiles
-API
-PODs
-adTie
-ProtocolEncoding
-prettyPrint
-Sisk's
-TableExtract
-Jochen
-Wiedmann
-Malcom
-Persico
-Wickline
-README
-Atomicity
-Passwd
-myfile
-parsers
-preassign

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libanydata-perl.git



More information about the Pkg-perl-cvs-commits mailing list