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.

In reply to Re: Perl database by Anonymous Monk
in thread Perl database by linex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.