|
Posted by Mumia W. on March 7, 2009, 7:35 pm
Please log in for more thread options
I'm planning to create a module named Tie::FlatFile::Hash. The module
will allow the programmer to create and access flatfile databases where
it is desired to make the database look like a hash (of arrays). The
format of the database will be user-defined. The module should work like
this:
tie %hash, 'Tie::FlatFile::Hash',
O_RDWR | O_CREAT, 0644, {
show/hide quoted text
packformat => 'A30A13N',
key => 0,
} or die("...");
The "packformat" option specifies that each record will contain three
fields, a thirty-character field, a thirteen-character field, and a
number. The "key" option tells the module that the first field (item 0)
will contain the virtual hash keys. So a record might contain a name (30
chars), phone number (13 chars), and a count of times that number has
called.
Assigning to the hash would create a record in the database. The
following code,
$hash{"John Malcolm"} = ['1718-555-0103', 26];
would create this in the database:
John Malcolm 1718-555-0103^@^@^@^Z
Tie::FlatFile::Hash would complement my Tie::FlatFile::Array. I haven't
yet decided if the former will use the latter behind the scenes. Is this
a good module idea? It the namespace proper?
|
key => 0,