I'm writing a script which will convert the gdbm files used by wreq to the
MySQL files used by BugZilla, but am having a serious problem. I can't seem
to open the gdbm files for reading.
Here's where the problem is:
# !/usr/local/bin/perl -w
use diagnostics;
# A bunch of currently undefined stuff was here
# Remove Before Flight
&reqTester;
# This is just to get the format/layout used by wreq
# so we know what we are dealing with
sub reqTester() {
use GDBM_File;
use Fcntl ':flock';
# We'll setup a few variables for use in this function
my %dbmFile;
my $filename='1/active';
# First we'll tie the database
$db = tie %dbmFile, 'GDBM_File', $filename , &GDBM_READER, 0444
or die "Unable to initialise database: $!\n";
$fd = $db->fd(); # This gets us a file descriptor
# Lets carefully open() the fle descriptor to get a
# Perl filehandle
open DATAFILE, "+<&=$fd" or die "Unable to safely open file: $!\n";
# Next we need to lock the database in shared mode,
# since we're just reading it, that's all we need
# at this point
print "Aquiring shared lock...";
flock(DATAFILE, LOCK_SH) or die "Unable to aquire shared lock: $!\n";
print "Lock aquired, Ready to read database\n\n";
# Lets dump the database so we can see what we have
foreach my $key(keys %dbmFile) {
# We'll just make the output pretty by double underlining
# each key, and give it one extra double underline
print "$key\n", ("=", x (length($key)+1)), "\n\n";
# Now print the value for each key
print "$dbmFile{$key}\n\n";
}
# Close the database
undef $db;
untie %dbmFile;
# We're all done now
exit;
}
About 98% of the above function comes from the 'Programming the Perl DBI'
book. The problem is when I run this script I get the following error message:
Uncaught exception from user code:
Unable to initialise database:
main::reqTester called at ./wreq-mysql.pl line 44
Commenting out the 'use diagnostics;' line only results in the removal of the
first and third lines in the error message.
Is there a reason why $! doesn't contain any information here?
Thanks in advance,
--
Michael D. Risser
Software Engineer
=============================
Machine Vision Products, Inc.
www.visionpro.com
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]