56
56
<li><a href="http://search.cpan.org">CPAN</a></li>
57
<li><a href="http://www.perl.org">Perl.org</a></li>
57
58
<li><a href="http://www.perl.com">Perl.com</a></li>
58
<li><a href="http://www.perl.org">Perl.org</a></li>
59
<li><a href="http://perlbuzz.com">Perl Buzz</a></li>
60
<li><a href="http://www.perlfoundation.org/perl5/index.cgi">Perl 5 Wiki</a></li>
61
<li><a href="http://jobs.perl.org">Perl Jobs</a></li>
59
62
<li><a href="http://www.pm.org">Perl Mongers</a></li>
60
63
<li><a href="http://www.perlmonks.org">Perl Monks</a></li>
61
64
<li><a href="http://planet.perl.org">Planet Perl</a></li>
66
69
<li>Site maintained by<br><a href="http://perl.jonallen.info">Jon Allen</a>
67
70
(<a href="http://perl.jonallen.info">JJ</a>)</li>
68
<li class="spaced">Last updated on<br>23 April 2006</li>
71
<li class="spaced">Last updated on<br>23 December 2007</li>
69
72
<li class="spaced">See the <a href="http://perl.jonallen.info/projects/perldoc">project page</a> for
76
79
<div id="centerContent">
77
80
<div id="contentHeader">
78
81
<div id="contentHeaderLeft"><a href="#" onClick="showLeft()">Show navigation</a></div>
79
<div id="contentHeaderCentre">-- Perl 5.8.8 documentation --</div>
82
<div id="contentHeaderCentre">-- Perl 5.10.0 documentation --</div>
80
83
<div id="contentHeaderRight"><a href="#" onClick="showRight()">Show toolbar</a></div>
82
85
<div id="breadCrumbs"><a href="index.html">Home</a> > <a href="index-modules-A.html">Core modules</a> > <a href="index-modules-F.html">F</a> > FileCache</div>
84
87
<div id="contentBody"><div class="title_container"><div class="page_title">FileCache</div></div><ul><li><a href="#NAME">NAME</a><li><a href="#SYNOPSIS">SYNOPSIS</a><li><a href="#DESCRIPTION">DESCRIPTION</a><li><a href="#CAVEATS">CAVEATS</a><li><a href="#BUGS">BUGS</a></ul><a name="NAME"></a><h1>NAME</h1>
85
88
<p>FileCache - keep more files open than the system permits</p>
86
89
<a name="SYNOPSIS"></a><h1>SYNOPSIS</h1>
87
<pre class="verbatim"> <a class="l_k" href="functions/use.html">use</a> <a class="l_w" href="FileCache.html">FileCache</a><span class="sc">;</span>
88
<span class="c"># or</span>
89
<a class="l_k" href="functions/use.html">use</a> <a class="l_w" href="FileCache.html">FileCache</a> maxopen <span class="cm">=></span> <span class="n">16</span><span class="sc">;</span></pre>
90
<pre class="verbatim"> cacheout <span class="i">$mode</span><span class="cm">,</span> <span class="i">$path</span><span class="sc">;</span>
91
<span class="c"># or</span>
92
cacheout <span class="i">$path</span><span class="sc">;</span>
90
<pre class="verbatim"> <a class="l_k" href="functions/use.html">use</a> <span class="w">FileCache</span><span class="sc">;</span>
91
<span class="c"># or</span>
92
<a class="l_k" href="functions/use.html">use</a> <span class="w">FileCache</span> <span class="w">maxopen</span> <span class="cm">=></span> <span class="n">16</span><span class="sc">;</span></pre>
93
<pre class="verbatim"> <span class="w">cacheout</span> <span class="i">$mode</span><span class="cm">,</span> <span class="i">$path</span><span class="sc">;</span>
94
<span class="c"># or</span>
95
<span class="w">cacheout</span> <span class="i">$path</span><span class="sc">;</span>
93
96
<a class="l_k" href="functions/print.html">print</a> <span class="i">$path</span> <span class="i">@data</span><span class="sc">;</span></pre>
94
<pre class="verbatim"> <span class="i">$fh</span> = cacheout <span class="i">$mode</span><span class="cm">,</span> <span class="i">$path</span><span class="sc">;</span>
97
<pre class="verbatim"> <span class="i">$fh</span> = <span class="w">cacheout</span> <span class="i">$mode</span><span class="cm">,</span> <span class="i">$path</span><span class="sc">;</span>
95
98
<span class="c"># or</span>
96
<span class="i">$fh</span> = cacheout <span class="i">$path</span><span class="sc">;</span>
99
<span class="i">$fh</span> = <span class="w">cacheout</span> <span class="i">$path</span><span class="sc">;</span>
97
100
<a class="l_k" href="functions/print.html">print</a> <span class="i">$fh</span> <span class="i">@data</span><span class="sc">;</span></pre>
98
101
<a name="DESCRIPTION"></a><h1>DESCRIPTION</h1>
99
<p>The <code class="inline">cacheout</code>
102
<p>The <code class="inline"><span class="w">cacheout</span></code>
100
103
function will make sure that there's a filehandle open
101
104
for reading or writing available as the pathname you give it. It
102
105
automatically closes and re-opens files if you exceed your system's
133
136
<a name="CAVEATS"></a><h1>CAVEATS</h1>
134
137
<p>While it is permissible to <code class="inline"><a class="l_k" href="functions/close.html">close</a></code> a FileCache managed file,
135
do not do so if you are calling <code class="inline">FileCache::cacheout</code>
138
do not do so if you are calling <code class="inline"><span class="w">FileCache::cacheout</span></code>
136
139
from a package other
137
140
than which it was imported, or with another module which overrides <code class="inline"><a class="l_k" href="functions/close.html">close</a></code>.
138
If you must, use <code class="inline">FileCache::cacheout_close</code>
141
If you must, use <code class="inline"><span class="w">FileCache::cacheout_close</span></code>
140
143
<p>Although FileCache can be used with piped opens ('-|' or '|-') doing so is
141
144
strongly discouraged. If FileCache finds it necessary to close and then reopen
146
149
close a file. When the file is reopened, the offset will be as specified by the
147
150
original <code class="inline"><a class="l_k" href="functions/open.html">open</a></code> file mode. This could be construed to be a bug.</p>
148
151
<a name="BUGS"></a><h1>BUGS</h1>
149
<p><i>sys/param.h</i> lies with its <code class="inline">NOFILE</code>
152
<p><i>sys/param.h</i> lies with its <code class="inline"><span class="w">NOFILE</span></code>
150
153
define on some systems,
151
154
so you may have to set <i>maxopen</i> yourself.</p>