Hashes of Arrays and databases

Jeff Zucker jeff at vpservices.com
Sun Dec 23 18:24:18 CST 2001

Joe Oppegaard wrote:
> I'm trying to add hashes of arrays to a database, but accessing those
> values again is the problem. First of all, is this even possible? I
> haven't seen any documentation that says it isn't, although I also have
> been able to find any code that actually does it either...

Curtis' suggestion to use Storable is a good one.  Another is to use one
of my AnyData modules, either AnyData.pm or, if you know SQL,
DBD::AnyData.pm.  The advantage is that they take care of all the tieing
and locking behind the scenes and provide ready made retrieval options
as well as standard methods for updating, deleting, or appending data.
For example:

  use AnyData;
  my $arrayref = [
        ["state", "city1", "city2", "city3" ],
        ["washington", "vancouver", "tacoma", "seattle" ],
        ["oregon", "portland", "eugene", "beaverton" ],
        ["arizona","tempe", "flagstaff", "sedona" ],
  my $table = adTie( 'ARRAY', $arrayref );
  print $table->{washington}->{city1}; # prints "vanvcouver";
  print $table->{oregon}->{city2}; # prints "eugene";
  adExport( $table, 'CSV','test1'  ); # save db as a CSV file

> The other option I've been considering is just inputting the
> data into a normal text file, but encrypting the information 

How do you think putting it into a DBM file protects you anymore than a
plain text file?  If you can get it in and out with DBM mods, so can
anyone else.  If you need it protected then you need encryption either


More information about the Pdx-pm-list mailing list