[comp.lang.perl] The strange case of dbmopen

Andrew.Vignaux@comp.vuw.ac.nz (Andrew Vignaux) (03/24/90)

Is there a way to make dbmopen() fail if the database doesn't exist?

My script wants to open a dbm database in the current directory.  If
the database is not there it means the user hasn't initialised things
or is running the script in the wrong directory.

I could check whether "foo.pag" exists and die with an appropriate
message but I was hoping that I wouldn't have to mention ".pag" or
".dir".

A slight modification to perl, perhaps?  How about "opening with a
MODE of 0 will fail if the database does not exist", e.g.
	dbmopen (FOO, "foo", 0) || die "can't open foo: $!";

I think that it's just a matter of perl only trying to create the
database if (mode != 0).

Unfortunately, this slightly overloads MODE and it will break all
those scripts that open the dbm file with a 0 mode, and then assume
that the database has been created (but is unreadable).  Perhaps
another value of MODE (-1)?

For a limited time only ...
 socket(S,2,1,6); connect(S,pack("SnNx8",2,2817,0x82c3060a)); print <S>, "\n";

Andrew
-- 
Domain address: Andrew.Vignaux@comp.vuw.ac.nz