Locking
Imagine that you've written a wonderful Perl program and that the whole world wants to use it. If you're on a Unix or Windows NT machine, or even on a Windows 95 or 98 machine, more than one person might be running your program at the same time. Or, your program may be put onto a Web server, and it's run so frequently that instances of your program overlap.
Now suppose that your program uses a database for its work, such as the text file database just described—but this discussion applies to any kind of database. Look at the following code, which uses functions described in the preceding section:
chomp($newrecord=<STDIN>); # Get a new record from the user @PHONEL=readdata(); # Read data into @PHONEL push(@PHONEL, $newrecord); # Put the ...
Get SAMS Teach Yourself Perl in 24 Hours THIRD EDITION now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.