in reply to WhichDBM_File?

$ perl -MSDBM_File -le 'print $SDBM_File::VERSION' 1.03

This should work for most well-behaved modules, though even good modules can be naughty.

Replies are listed 'Best First'.
Re: Re: WhichDBM_File?
by Dr. Mu (Hermit) on Apr 20, 2004 at 04:30 UTC
    I guess I phrased the question poorly. I'm not after the version number of any particular DBM module; but rather I need to know which DBM module a particular installation of Perl uses by default if you don't specify one.

      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
        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.