Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


Search this Thread
Old 09-20-2002, 11:56 PM   #1
LQ Newbie
Registered: Aug 2002
Location: Stockholm, Sweden
Distribution: Red Hat 7.x
Posts: 7

Rep: Reputation: 0
Reading Berkeley DB 1.85 in perl

I have a bunch of databases from an old forum system that I really want to extract the information from. Unfortunately the version of perl that I run now can't seem to load these files at all.

When running file on the db files I get this:
bash-2.05# file data/eon.db
data/eon.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)
The old script used this to load the db:
dbmopen (%DB, "$db_dir/$db", 0644)
I'm using Perl 5.6.1 at the moment, installed from an rpm, the old perl version must have been 5.004 or maybe even earlier, from RH5.x I believe.

I've tried using tie together with different DB types, like DB_File, GDBM_File and SDBM_File but nothing seems to work.

Does anyone know what I'm doing wrong or have any insight at all that could help me?
Old 09-23-2002, 11:26 AM   #2
Registered: Sep 2002
Location: Tulsa, OK
Distribution: Slack, baby!
Posts: 349

Rep: Reputation: 33
The message "data/eon.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)" doesn't necessarily sound like an error code. I am assuming that file is a perl script? Can you post the code segment related to opening and reading the DB?
Old 01-25-2003, 08:14 PM   #3
LQ Newbie
Registered: Aug 2002
Location: Stockholm, Sweden
Distribution: Red Hat 7.x
Posts: 7

Original Poster
Rep: Reputation: 0
The command file is the standard program to determine a file type, I showed the output to show what type of DB it is.

The db files were created by a very old version of the forum system called WWWThreads and I want to extract the information to insert it into the MySQL database the new version uses. The old version is very old and hasn't been supported by the programmer for a long time.

Here is the part of the script that is trying to read this db file (this script used to work on an old perl version, but it broke when I upgraded a long time ago):
use vars qw(%DB %BI $board_index);
use strict;
use CGI;
use DB_File;

        my $db_dir     = '/path/to/data';
        my $db         = 'dbname';

        dbmopen (%DB, "$db_dir/$db", 0644) or die "Can't open board: $db. Reason
        foreach (reverse 0 .. $DB{'TOTAL'}) {   
                if ($DB{$_}) {
                        @data = split (/\t/, $DB{$_});
                        if ($data[0] eq "Main") {
        dbmclose (%DB) or die "Can't close board: $db. Reason: $!";
I've removed a lot of the code to save space, the problem is that dbmopen won't recognize the database at all.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mysql reading via Perl DBI ivanatora Programming 2 03-21-2007 05:03 AM
Perl - Reading Real Time streams vitoal18t Programming 10 05-18-2005 07:59 AM
Need Help in Reading a rather complex textile in perl!! domquem Programming 9 01-03-2005 02:39 PM
Perl and Berkeley db zolley Linux - Newbie 0 06-07-2004 06:43 AM
perl reading pdf,ps,txt j-ray Programming 1 02-04-2003 11:49 AM

All times are GMT -5. The time now is 06:07 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration