in reply to Re: Re: WhichDBM_File?
in thread WhichDBM_File?

I misunderstood. perrin has it right. Here's what I used on 5.6.1, but I don't have a 5.5 to try it on.

#!/usr/bin/perl -wl use strict; no strict 'refs'; # Nothing there yet! print "AnyDBM_File::ISA = ", @AnyDBM_File::ISA; dbmopen my %db, "foo", 0777; my $pkg = ref tied %db; print $pkg; my @isa = @{"${pkg}::ISA"}; print @isa; print ${"$isa[0]::VERSION"} __END__ AnyDBM_File::ISA = AnyDBM_File SDBM_File 1.03

Replies are listed 'Best First'.
Re: Re: Re: Re: WhichDBM_File?
by Dr. Mu (Hermit) on Apr 20, 2004 at 06:07 UTC
    Nice script! I used it on both systems and got, on mine (Perl 5.8):
    AnyDBM_File::ISA = AnyDBM_File NDBM_File 1.04
    On my hosting service (Perl 5.005), I got:
    AnyDBM_File::ISA = AnyDBM_File NDBM_File 1.01
    That's a version difference of only 0.03. So the puzzle remains as to why they produce such different files and how I can reconcile the two.

      Disclaimer: My experience with Perl's dbm is quite limited.

      My guess is that they are using different versions of the ndbm backend, though the interface stays the same to Perl. Does ndbm guarantee to be portable across systems anyway?

      I can't tell from your post what the constraints of "reconciling" are. The only sure-fire way I know is to rewrite to use a different storage mechanism. Perhaps Storable or Data::Dumper might be of use.

        "Reconciling" can occur on a couple different levels:
        1. Identical scripts work identically on both systems, even though the actual data storage may be different.
        2. Files created on one system are interchangable with those on the other.
        Number one is an issue right now because of a short-sighted decision I made several years ago. That was to apply locking to the actual datafiles, rather than to separate lockfiles. Not smart because, to do so, I have to know the name of the data file. And now they're different between the two systems. Oops! That may be easy to remedy, though.

        Number two is harder, because I've got archival data I'd just as soon not have to recreate just to accomodate a different DBM. I suppose some sort of conversion routine might not be out of the question, however.