deibyz has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

Assume I have a DB_File tied hash created in memory, with something in the lines of:

my $db = tie my %h, "DB_File", undef, O_RDWR|O_CREAT
After populating it with some key/value pairs (potentially many), given some conditions I would like to create a proper db_file on disk with this data, but I would like to do it directly, without having to go through each %$h or something like that, to avoid performance penalties. I've been searching in the DB_File and dbopen documentations, but haven't found anyway to do it. Any ideas? Regards, D.

Replies are listed 'Best First'.
Re: Dump In-memory DB_File to disk
by BioLion (Curate) on Oct 06, 2009 at 11:33 UTC

    Using ad_export from DBD::AnyData you can convert in-memory databases into a file of specified format, including DBI databases. You can also pump out a host of other formats too.

    This may require some re-organising of your datastructure though? Possibly a silly thought, possibly not, but i am not sure how compliant Berkley DB and DBI are... Although by the looks of it, DBD::AnyData seems to support many database formats. HTH.

    Just a something something...
      That would be slower than direct approach
Re: Dump In-memory DB_File to disk
by Anonymous Monk on Oct 06, 2009 at 11:41 UTC