Thanks for your help everyone. I spent days looking for documentation on flocking databases but literally found nothing because I was told it was totally different than flocking just a basic filehandle. In any case the link jeffa tossed up was the solution to my problem.
Who would have thought flocking a file could be so easy? All you do is add the line flock(FILEHANDLE, NUM) || die; :)
"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"
sulfericacid | [reply] [d/l] |
And that is bad advice for this context. Working with dbm style files isn't like working with plain files. Originally the Perl Cookbook used such an approach and while I can't find an exact mention of the problem there's a quick overview at What about table and file locking?. So - if you follow only the advice in the link jeffa gave you then you'll be only part way there. In general, if you've got flock() in your code and you're working with a database then you did something wrong. jeffa didn't help you here at all. Bad jeffa.
| [reply] |
Usually i am good about saying stuff like "here is some more
advice to go along with diotalevi's even more excellent
advice." This time i didn't. bad jeffa.
diotalevi, if you are upset that sulfericacid did not
take your advice to use BerkeleyDB, then i am sorry
that i carved a "path of least resistance" for
sulfericacid.
That is not what i meant at all. Since sulfericacid did
not (apparantly) know about anything about file locking at
all, i thought "why not ask him to read one of our
tutorials?" I think you would rather sulfericacid had
read that tutorial than not ... now sulfericacid has some
background to work with. That's good.
sulfericacid ... now that you know about file locking,
you really should give BerkeleyDB a whirl. Then,
once you have mastered that, try out the even cooler
SQLite (by the way ...
DBD::SQLite is merely the Perl driver for SQLite).
SQL is indeed a hurdle you have to spend time to overcome
... but once you learn it, when the time comes to start using a real RDMS (Postgres, MySQL, Oracle, etc.) you will already be ready for it.
Oh, and since no one has said it yet ... turnstep++ for
her excellent tutorial. ;)
jeffa
"The path of least resistance always leads you to the
least everytime." -- Ty Hagar
| [reply] |