1FileCache(3pm) Perl Programmers Reference Guide FileCache(3pm)
2
3
4
6 FileCache - keep more files open than the system permits
7
9 no strict 'refs';
10
11 use FileCache;
12 # or
13 use FileCache maxopen => 16;
14
15 cacheout $mode, $path;
16 # or
17 cacheout $path;
18 print $path @data;
19
20 $fh = cacheout $mode, $path;
21 # or
22 $fh = cacheout $path;
23 print $fh @data;
24
26 The "cacheout" function will make sure that there's a filehandle open
27 for reading or writing available as the pathname you give it. It
28 automatically closes and re-opens files if you exceed your system's
29 maximum number of file descriptors, or the suggested maximum maxopen.
30
31 cacheout EXPR
32 The 1-argument form of cacheout will open a file for writing ('>')
33 on it's first use, and appending ('>>') thereafter.
34
35 Returns EXPR on success for convenience. You may neglect the return
36 value and manipulate EXPR as the filehandle directly if you prefer.
37
38 cacheout MODE, EXPR
39 The 2-argument form of cacheout will use the supplied mode for the
40 initial and subsequent openings. Most valid modes for 3-argument
41 "open" are supported namely; '>', '+>', '<', '<+', '>>', '|-' and
42 '-|'
43
44 To pass supplemental arguments to a program opened with '|-' or
45 '-|' append them to the command string as you would system EXPR.
46
47 Returns EXPR on success for convenience. You may neglect the return
48 value and manipulate EXPR as the filehandle directly if you prefer.
49
51 While it is permissible to "close" a FileCache managed file, do not do
52 so if you are calling "FileCache::cacheout" from a package other than
53 which it was imported, or with another module which overrides "close".
54 If you must, use "FileCache::cacheout_close".
55
56 Although FileCache can be used with piped opens ('-|' or '|-') doing so
57 is strongly discouraged. If FileCache finds it necessary to close and
58 then reopen a pipe, the command at the far end of the pipe will be
59 reexecuted - the results of performing IO on FileCache'd pipes is
60 unlikely to be what you expect. The ability to use FileCache on pipes
61 may be removed in a future release.
62
63 FileCache does not store the current file offset if it finds it
64 necessary to close a file. When the file is reopened, the offset will
65 be as specified by the original "open" file mode. This could be
66 construed to be a bug.
67
68 The module functionality relies on symbolic references, so things will
69 break under 'use strict' unless 'no strict "refs"' is also specified.
70
72 sys/param.h lies with its "NOFILE" define on some systems, so you may
73 have to set maxopen yourself.
74
75
76
77perl v5.32.1 2021-05-31 FileCache(3pm)