How to read Perl DB_Files in Ruby
-
19-09-2019 - |
Question
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?
Solution
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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow