Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!uhccux!munnari.oz.au!kaukau.comp.vuw.ac.nz!ajv From: Andrew.Vignaux@comp.vuw.ac.nz (Andrew Vignaux) Newsgroups: comp.lang.perl Subject: The strange case of dbmopen() and the missing database Message-ID: <1990Mar24.094601.25884@kaukau.comp.vuw.ac.nz> Date: 24 Mar 90 09:46:01 GMT Sender: news@kaukau.comp.vuw.ac.nz (News Admin) Reply-To: ajv@comp.vuw.ac.nz (Andrew Vignaux) Organization: Comp Sci, Victoria University, Wellington, New Zealand. Lines: 28 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 , "\n"; Andrew -- Domain address: Andrew.Vignaux@comp.vuw.ac.nz