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?

Andy Lester
  • 91,102
  • 13
  • 100
  • 152
Jonas Elfström
  • 30,834
  • 6
  • 70
  • 106

1 Answers1

3

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
  • 30,834
  • 6
  • 70
  • 106