in reply to Re: dbmopen() test if file exists already?
in thread dbmopen() test if file exists already?

>since dbmopen doesn't clobber the data >this test seems rather frivolous.

Didn't say it did.

I was thinking about some data structure where, for example, user details could be stored in that kind of tied hash, and so you might want to check if you already had a "codypendant.db" or a "broquaint.db" when a new user came along, in case of duplication.

I really should learn Tie::Hash shouldn't I? --

“Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
M-J D

Replies are listed 'Best First'.
Re: Re: Re: dbmopen() test if file exists already?
by broquaint (Abbot) on May 28, 2003 at 13:13 UTC
    I was thinking about some data structure where, for example, user details could be stored in that kind of tied hash, and so you might want to check if you already had a "codypendant.db" or a "broquaint.db" when a new user came along, in case of duplication.
    This sounds like a case for creating a single hash, where each user is a key, then it would just be a matter testing the existence of a user with exists %user_db. If however, you've decided to do it on a per file basis for whatever reason then it would just be a matter of testing the return status of dbmopen e.g
    dbmopen(my %hash, "codypendant") and warn "codypendant already exists";

    HTH

    _________
    broquaint