in reply to Re^3: Proper way of passing around tie'd variable
in thread Proper way of passing around tie'd variable
I see what you mean. All that code that I am using came directly from the book CGI Programming with Perl , Chapter 10, Section 2 ("DBM Files"). I am not very experienced with file locking, and I wasn't really interested in the syncronization stuff when we covered it in my OS class (semaphores still send shivers up my spine). I figured I could just copy and paste the code from the book to get it to work, but I guess I was wrong.
So how do you suggest I deal with file locking? As explained in the book, the point of the $db variable is to get the file descriptor. Once that is done, we 'undef' it to decrement the reference count. That way, when hash is untie'd, the changes made to hash are committed to the file. But I guess instead of doing all that, I can use a different file as a lock?
I still find it peculiar that things work when there is a Dumper call in hash_init that reads the values. Can anybody explain why that happens?
Also, can you tell me what you had to change in the code that I posted? Because that really is what I am using..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Proper way of passing around tie'd variable
by kyle (Abbot) on Jan 07, 2008 at 18:20 UTC |