[Cover] [Previous Section] [Next Section] [Index]
Current chapter: Perl File Utilities
Section 60 out of 79 total sections
, Section 2 out of 5 sections in this chapter
OpenWithLock()
Description
Opens a file handle on the file and locks the file, causing the process to block until the file is open.
Synopsis
require 'FileUtils.pl';
...
&AppUtils::OpenWithLock($fh, $fname, $lockType);
Arguments
|
Argument
|
Meaning
|
$fh
|
Reference to the file handle to lock.
|
$fname
|
The name of the file to open.
|
$lockType
|
The type of lock with which to lock the file. Specify READ or WRITE. The default is WRITE.
|
Returns
|
Value
|
Meaning
|
TRUE
|
Success.
|
undefined
|
Failure.
|
Examples
To lock a file for reading, you must open the file for input. For example, the following code opens and locks myfile for reading:
. . .
&AppUtils::OpenWithLock(*FD, "<myfile", 'READ');
. . .
To lock a file for writing, you must open the file for output. For example, the following code opens and locks myfile for writing:
. . .
&AppUtils::OpenWithLock(*FD, ">myfile", 'WRITE');
. . .
[Cover] [Previous Section] [Next Section] [Index]
Current chapter: Perl File Utilities
Section 60 out of 79 total sections
, Section 2 out of 5 sections in this chapter
Copyright © 1999, Unwired Planet, Inc. All rights
reserved.