On Thu, 9 Sep 2004, Johann Spies wrote:

We have a situation that we need to open a dbm-file but cannot do so using perl version 5.8.4-2 on Debian Sarge. The following script fails, but the same script and dbm-file works on Woody with perl 5.6:

Apparently, DBM files can get messed up if you create them with one version of the DBM but then work with them under another. Unlike about all other modules, this is something that has to be handled when Perl itself is compiled, and the DBM engine that that instance of Perl is linked to has to stay the same forever. Or something. It's complicated.


See <http://www.perldoc.com/perl5.8.4/pod/perltrap.html#DBM-Traps> (scan down a bit for the string 'dbm' -- the anchor doesn't actually go to the right section of the document, but it's almost at the end).

My understanding is that the best workaround for this these days is to use AnyDBM_File, or a "real" database engine & driver. See:

    <http://www.perldoc.com/perl5.8.4/lib/AnyDBM_File.html>
    <http://search.cpan.org/~nwclark/perl-5.8.5/lib/AnyDBM_File.pm>

For things that used to be done in DBM variants, SQLite has been getting very popular recently. It's a small, fast, way to get SQL query access to structured disc files (which arguably makes it a better MySQL than MySQL, considering the features that database has been adding lately). Moreover, it shouldn't have these problems with static linking that have been annoying DBM users for years now.

Read more about it:

    <http://search.cpan.org/~msergeant/DBD-SQLite-1.04/lib/DBD/SQLite.pm>
    <http://www.perl.com/pub/a/2003/09/03/perlcookbook.html>

If you're not already locked in with DBM, SQLite may be much easier.


-- Chris Devers

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to