Problem with DB_FIle and Perl 5.12
"Eric Robertson" <[email protected]> Wed, 24 Aug 2011 17:08:37 +0100
| Newsgroups | gmane.comp.lang.perl.active-perl |
|---|---|
| Message-ID | <75CF17A4359F4E68B80B92C58C0BE59C@macbookXP> |
I have a problem with DB_File and Perl 5.12. I posted a message on the ASPN message board but no one there has come back with an
answer so Im trying here.
I have some Perl CGI scripts which were developed some time ago using ActivePerl 5.8. When my Mac OS started using 5.10 I considered
upgrading my version of ActivePerl to 5.10 but I couldn't find a couple of modules I needed - DBD::CSV and DBD::mysql - so I decided
to continue to use 5.8. These scripts produce BerkeleyDB files using DB_File and I found that when I was remotely debugging these
scripts on my virtual host on the Mac these files could be read OK although the Mac was using the inbuilt 5.10 because the scripts
contained the normal /usr/bin/perl shebang line.
I've recently upgraded the Mac's OS to Lion and I see that the inbuilt Perl version has been changed to 5.12. I now find that I get
an error when I try to read the BerkeleyDB files. I've used the followed code to test the situation and found that 5.12 won't access
files produced by ActivePerl 5.8 and vice versa - the error message is "Can't open test.dbm: Inappropriate file type or format".
use strict;
use Fcntl;
use DB_File;
my $file = 'test.dbm';
my %dbase;
my $error;
tie (%dbase, 'DB_File', $file, O_RDWR|O_CREAT, 0666, $DB_BTREE) || ($error=1);
if ($error) {
print "Can't open $file: $!\n";
}
$dbase{1} = 'one';
$dbase{2} = 'two';
$dbase{3} = 'three';
untie %dbase;
tie (%dbase, 'DB_File', $file, O_RDONLY, 0666, $DB_BTREE) || ($error=1);
if ($error) {
print "Can't open $file: $!\n";
}
Is the problem something to do with the BerkeleyDB code rather than Perl and how can I correct this? I know I could change the
shebang line in my code when testing on my server but I'd have to remember to change this before I uploaded the code to the live
server - which I'm likely to forget!
Eric Robertson
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs