4 use Memoize 0.52 qw(memoize unmemoize);
6 use Memoize::AnyDBM_File;
14 $ARG = 'Keith Bostic is a pinhead';
26 if (eval {require File::Spec::Functions}) {
27 File::Spec::Functions->import(qw(catfile tmpdir));
30 *catfile = sub { join '/', @_ };
31 $tmpdir = $ENV{TMP} || $ENV{TMPDIR} || '/tmp';
33 $file = catfile($tmpdir, "md$$");
34 @files = ($file, "$file.db", "$file.dir", "$file.pag");
35 1 while unlink @files;
38 tryout('Memoize::AnyDBM_File', $file, 1); # Test 1..4
39 # tryout('DB_File', $file, 1); # Test 1..4
40 1 while unlink $file, "$file.dir", "$file.pag";
43 my ($tiepack, $file, $testno) = @_;
45 tie my %cache => $tiepack, $file, O_RDWR | O_CREAT, 0666
49 SCALAR_CACHE => [HASH => \%cache],
55 print (($t1 == 5) ? "ok $testno\n" : "not ok $testno\n");
57 print (($t2 == 5) ? "ok $testno\n" : "not ok $testno\n");
60 # Now something tricky---we'll memoize c23 with the wrong table that
61 # has the 5 already cached.
63 SCALAR_CACHE => ['HASH', \%cache],
70 print (($t3 == 5) ? "ok $testno\n" : "not ok $testno # Result $t3\n");
72 print (($t4 == 5) ? "ok $testno\n" : "not ok $testno # Result $t4\n");
77 my @present = grep -e, @files;
78 if (@present && (@failed = grep { not unlink } @present)) {
79 warn "Can't unlink @failed! ($!)";