in reply to Perl database

Perhaps you are looking for a NDBM_File or DB_File database. basically is allows one to create a file to store a simple hashed array. I would suggest reading up on the tie function and the documentation for the AnyDBM_File module.
use NBDM_File; tie %hash, '/some/path/databasefile', 1, 0; $hash{'key'} = 'value'; my $value = $hash{'key'}; untie %hash;
Although tie is pretty good for simple hashes, it does not store complex objects. In order to do that you can simply use a FreezeThaw to change between a complex memory structure and a string. So something like this...
use FreezeThaw qw/freeze thaw/; # Store information my $cdobject = { 'title' => 'My Music', 'author' => 'Me', 'tracks' => [ {'title' => 'songA', 'length' => '1:00'}, {'title' => 'songB', 'length' => '1:50'} ] }; my $cdfrozen = freeze($cdobject); $hash{ $cdobject->{'title'} } = $cdfrozen. # Retrieve information my $cd = thaw( $hash{'My Music'} ); printf "Album %s with %s tracks\n", $cd->{'title'}, $#{$cd->{'tracks'}};
Then, of course, you can get fancy. Like setting up a different hash for each index you want. And in order to keep the data 'synchronized' you can have the index hashes point to an entry ID with a master hash storing each entry ID mapped to a frozen object. Or better yet, even roll your own Perl module that will do all the management of the index databases and the main database for you and just have a simple object oriented interface to work with the information. However at that point you have basically written your own RDBMS and might as well setup MySQL or PostgreSQL.

Replies are listed 'Best First'.
Re: Re: Perl database
by Anonymous Monk on Apr 14, 2004 at 19:39 UTC
    I just realized my tie statement was wrong.
    tie %hash, 'NDBM_File', '/some/path/databasefile', 1, 0;
    Aaaaah, much better.