1#!./perl 2 3use FileCache maxopen => 2; 4our @files; 5BEGIN { @files = map { "append_$_" } qw(foo bar baz quux Foo_Bar) } 6END { 1 while unlink @files } 7 8use Test::More tests => 2; 9 10{# Test 3: that we open for append on second viewing 11 my @cat; 12 for my $path ( @files ){ 13 cacheout $path; 14 print $path "$path 3\n"; 15 } 16 for my $path ( @files ){ 17 cacheout $path; 18 print $path "$path 33\n"; 19 } 20 for my $path ( @files ){ 21 open($path, '<', $path); 22 push @cat, do{ local $/; <$path>}; 23 close($path); 24 } 25 26 ok(scalar(grep/\b3$/m, @cat) == scalar(@files)); 27 28 @cat = (); 29 for my $path ( @files ){ 30 cacheout $path; 31 print $path "$path 333\n"; 32 } 33 for my $path ( @files ){ 34 open($path, '<', $path); 35 push @cat, do{ local $/; <$path>}; 36 close($path); 37 } 38 ok(scalar(grep /\b33$/m, @cat) == scalar(@files)); 39} 40