X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/55204971972392ce5a252fbbd6d78b1c48ed70e3..789bd863840ef4ff6c46f7c2ee0f3f64e0b5daa6:/lib/cacheout.pl diff --git a/lib/cacheout.pl b/lib/cacheout.pl index bec40bd..368e98e 100644 --- a/lib/cacheout.pl +++ b/lib/cacheout.pl @@ -1,4 +1,13 @@ -#!/usr/bin/perl +# +# This library is no longer being maintained, and is included for backward +# compatibility with Perl 4 programs which may require it. +# This legacy library is deprecated and will be removed in a future +# release of perl. +# +# In particular, this should not be used as an example of modern Perl +# programming techniques. +# +# Suggested alternative: FileCache # Open in their package. @@ -6,6 +15,12 @@ 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 +32,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 +46,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+)/; }