views:

57

answers:

1

I'm migrating a Perl script to Ruby. The Perl script uses DB_File in DB_HASH mode. How do I read all the keys and values from such a file in Ruby?

+1  A: 

I finally realized that DB_HASH is a Berkeley DB file format.

I didn't have libdb for Ruby on my Ubuntu box but that was fixed with a simple apt-get

apt-get install libdb4.2-ruby1.8

Then in Ruby

require 'bdb'
db=BDB::Hash.open("test.db")
keyvalues=db.to_hash
Jonas Elfström