X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fcacheout.pl;h=64378cffc6f00d8f5839ab2e62ea86b25cda44ff;hb=f02a87dff8d75d4e8d0bada37f4abde41184909e;hp=bec40bde62beb5077a26e1a7b41539e2b8301653;hpb=55204971972392ce5a252fbbd6d78b1c48ed70e3;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/cacheout.pl b/lib/cacheout.pl index bec40bd..64378cf 100644 --- a/lib/cacheout.pl +++ b/lib/cacheout.pl @@ -1,11 +1,15 @@ -#!/usr/bin/perl - # Open in their package. sub cacheout'open { open($_[0], $_[1]); } +# Close as well + +sub cacheout'close { + close($_[0]); +} + # But only this sub name is visible to them. sub cacheout { @@ -17,7 +21,7 @@ sub cacheout { local(@lru) = sort {$isopen{$a} <=> $isopen{$b};} keys(%isopen); splice(@lru, $maxopen / 3); $numopen -= @lru; - for (@lru) { close $_; delete $isopen{$_}; } + for (@lru) { &close($_); delete $isopen{$_}; } } &open($file, ($saw{$file}++ ? '>>' : '>') . $file) || die "Can't create $file: $!\n"; @@ -31,7 +35,7 @@ $seq = 0; $numopen = 0; if (open(PARAM,'/usr/include/sys/param.h')) { - local($.); + local($_, $.); while () { $maxopen = $1 - 4 if /^\s*#\s*define\s+NOFILE\s+(\d+)/; }