use FileCache; cacheout $path; # open the file whose path name is $path print $path "stuff\n"; # print stuff to file given by $path
The
cacheout()
subroutine makes sure that the file whose name is
$path
is created and accessible through the filehandle also named
$path
. It permits you to write to more files than your system allows to be open at once, performing the necessary opens and closes in the background. By preceding each file access with:
cacheout $path;
you can be sure that the named file will be open and ready to do business. However, you do not need to invoke
cacheout()
between successive accesses to the same file.
cacheout()
does not create directories for you. If you use it to open an existing file that FileCache is seeing for the first time, the file will be truncated to zero length with no questions asked. (However, in its opening and closing of files in the background,
cacheout()
keeps track of which files it has opened before and does not overwrite them, but appends to them instead.)
cacheout()
checks the value of
NOFILE
in
sys/param.h
to determine the number of open files allowed. This value is incorrect on some systems, in which case you should set
$FileCache::maxopen
to be four less than the correct value for
NOFILE
.
7.2.31 File::Path - Create or Remove a Series of Directories | 7.2.33 FileHandle - Supply Object Methods for Filehandles |