[Cover] [Previous Section] [Next Section] [Index]
Current chapter: Perl File Utilities
Section 61 out of 79 total sections
, Section 3 out of 5 sections in this chapter
CloseWithLock()
Description
Closes and unlocks a file handle that has been opened using OpenWithLock().
Synopsis
require 'FileUtils.pl';
...
&AppUtils::CloseWithLock($fh);
Arguments
|
Argument
|
Meaning
|
$fh
|
Reference to the file handle to unlock and close.
|
Example
The following code generates a deck with a counter.
#!/usr/local/bin/perl5.001
#
require 'FileUtils.pl';
require 'HDMLUtils.pl';
&AppUtils::OpenWithLock(*CTRFILE, '+<ctr.txt', 'WRITE') ||
&AppUtils::OpenWithLock(*CTRFILE, '+>ctr.txt', 'WRITE');
$times = <CTRFILE>;
if($times > 0)
{
$times = $times + 1;
}
else
{
$times = 1;
}
seek(CTRFILE, 0,0);
print CTRFILE "$times";
&AppUtils::CloseWithLock(CTRFILE);
$DECK =
"<HDML VERSION=2.0 TTL=0>".
"<DISPLAY>".
"This deck has been called $times times".
"</DISPLAY>".
"</HDML>";
&AppUtils::OutputDeck($DECK);
FIGURE 11-1.
Simple deck with a counter
[Cover] [Previous Section] [Next Section] [Index]
Current chapter: Perl File Utilities
Section 61 out of 79 total sections
, Section 3 out of 5 sections in this chapter
Copyright © 1999, Unwired Planet, Inc. All rights
reserved.