| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# This library is no longer being maintained, and is included for backward |
|
3
|
|
|
|
|
|
|
# compatibility with Perl 4 programs which may require it. |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# In particular, this should not be used as an example of modern Perl |
|
6
|
|
|
|
|
|
|
# programming techniques. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# Suggested alternative: FileCache |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Open in their package. |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
1049
|
no warnings "ambiguous"; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
353
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub cacheout::open { |
|
15
|
0
|
|
|
0
|
|
|
open($_[0], $_[1]); |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Close as well |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub cacheout::close { |
|
21
|
0
|
|
|
0
|
|
|
close($_[0]); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# But only this sub name is visible to them. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub cacheout { |
|
27
|
|
|
|
|
|
|
package cacheout; |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
|
|
0
|
|
|
($file) = @_; |
|
30
|
0
|
0
|
|
|
|
|
if (!$isopen{$file}) { |
|
31
|
0
|
0
|
|
|
|
|
if (++$numopen > $maxopen) { |
|
32
|
0
|
|
|
|
|
|
local(@lru) = sort {$isopen{$a} <=> $isopen{$b};} keys(%isopen); |
|
|
0
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
splice(@lru, $maxopen / 3); |
|
34
|
0
|
|
|
|
|
|
$numopen -= @lru; |
|
35
|
0
|
|
|
|
|
|
for (@lru) { &close($_); delete $isopen{$_}; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
|
37
|
0
|
0
|
|
|
|
|
&open($file, ($saw{$file}++ ? '>>' : '>') . $file) |
|
|
|
0
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|| die "Can't create $file: $!\n"; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
0
|
|
|
|
|
|
$isopen{$file} = ++$seq; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
package cacheout; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$seq = 0; |
|
46
|
|
|
|
|
|
|
$numopen = 0; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
if (open(PARAM,'/usr/include/sys/param.h')) { |
|
49
|
|
|
|
|
|
|
local($_, $.); |
|
50
|
|
|
|
|
|
|
while () { |
|
51
|
|
|
|
|
|
|
$maxopen = $1 - 4 if /^\s*#\s*define\s+NOFILE\s+(\d+)/; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
close PARAM; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
$maxopen = 16 unless $maxopen; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |