Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Can anyone pleaaase tell me what the most secure method of flocking is, or know of? I'm so lost, and going out of my mind :(
I started a thread here, and I was so thankful that mirod had answered me, and I thought my troubles were over :) Unfortunately I'm still having trouble with this. I left my last post there on March 12th, which I think has gotten lost with all the other posts, since no one has answered, and I don't know how to bump it up :)
I've been trying to read everything I could here and have managed to find these:
Everyone seems to have their own ways of doing this, and after reading and trying to understand, I've stayed on with KM's way of file locking. But as I said with my last post it still does not work.What could I possibly be doing wrong? I also use this method as well.. is this wrong?
Example::
From what I understand this method should be locking all the files that are being read/written to? or Have I misunderstood? Both examples I have used still wipes my file clean every so often :($SEMAPHORE = $tempfile . '.lck'; open(S, ">$SEMAPHORE") or die "$SEMAPHORE: $!"; flock(S, LOCK_EX) or die "flock() failed for $SEMAPHORE: $!"; open (TEMP, ">$tempfile") or die "Can't open $tempfile: $!"; open (FH, "$file") or die "Can't open $file: $!"; while (<FH>) { ## do_something; } close FH; close TEMP; rename($tempfile,$file); close S;
Sorry for the long post, I feel like an idiot :(
Thanks so much
PS.. Is there a way to search the posts here on the monastery? Using the search box that appears at the tops of the pages just locates the perl man explainations.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: flock() ..I really need a hand .. please :)
by AgentM (Curate) on Mar 20, 2001 at 10:01 UTC | |
by Anonymous Monk on Mar 20, 2001 at 12:17 UTC | |
by AgentM (Curate) on Mar 20, 2001 at 12:23 UTC | |
|
Re: flock() ..I really need a hand .. please :)
by turnstep (Parson) on Mar 20, 2001 at 07:41 UTC | |
|
Re: flock() ..I really need a hand .. please :)
by a (Friar) on Mar 20, 2001 at 09:59 UTC | |
by Anonymous Monk on Mar 20, 2001 at 13:47 UTC |