On Tue, Mar 30, 1999 at 08:23:09PM -0000, Efg� wrote:
> On a related note, has anyone written perl code to read (maybe write)
> a cdb ?
It's easy to write something that puts the data into the right format and pipes
into cdbmake (which comes with the cdb package).
>From the cdbmake man page:
A record is encoded for cdbmake as +klen,dlen:key->data
followed by a newline. Here klen is the number of bytes
in key and dlen is the number of bytes in data. The end
of data is indicated by an extra newline. For example:
+3,5:one->Hello
+3,7:two->Goodbye
key and data may contain any characters, including colons,
dashes, newlines, and nulls.
In your perl script, just open a pipe to cdbmake and write your data in the
above format.
I haven't tried to do any cdb reading with perl, but it's easy enough with C by
linking with libcdb.a and using cdb_seek and cdb_bread.
Chris