June 2005
Beginner
480 pages
10h 31m
English
| Q1: | Can I store the structures from Hour 13, “References and Structures,” in a DBM file or a text file? |
| A1: | The short answer is no, not easily. The longer answer is yes, but first you need to convert the “structure” over to a string that represents the data and the structure that contains it, and you then need to use that as a value in the DBM-tied hash. The module to do so is Data::Dumper. |
| Q2: | How do I lock DBM files? |
| A2: | DBM files can be locked using the semaphore locking system shown previously. Simply use the get_lock() and release_lock() functions from Listing 15.3 and put these around the DBM open and close functions:
get_lock(); dbmopen(%hash, "foo", 0644) || die "dmbopen: $!"; $hash{newkey}="Value"; dbmclose(%hash); release_lock(); ... |
Read now
Unlock full access