2 # This library is no longer being maintained, and is included for backward
3 # compatibility with Perl 4 programs which may require it.
4 # This legacy library is deprecated and will be removed in a future
7 # In particular, this should not be used as an example of modern Perl
8 # programming techniques.
10 # Suggested alternative: FileCache
12 warn( "The 'cacheout.pl' legacy library is deprecated and will be"
13 . " removed in the next major release of perl. Please use the"
14 . " FileCache module instead." );
16 # Open in their package.
28 # But only this sub name is visible to them.
34 if (!$isopen{$file}) {
35 if (++$numopen > $maxopen) {
36 local(@lru) = sort {$isopen{$a} <=> $isopen{$b};} keys(%isopen);
37 splice(@lru, $maxopen / 3);
39 for (@lru) { &close($_); delete $isopen{$_}; }
41 &open($file, ($saw{$file}++ ? '>>' : '>') . $file)
42 || die "Can't create $file: $!\n";
44 $isopen{$file} = ++$seq;
52 if (open(PARAM,'/usr/include/sys/param.h')) {
55 $maxopen = $1 - 4 if /^\s*#\s*define\s+NOFILE\s+(\d+)/;
59 $maxopen = 16 unless $maxopen;