4 use Memoize 0.52 qw(memoize unmemoize);
6 use Memoize::AnyDBM_File;
14 $ARG = 'Keith Bostic is a pinhead';
26 $tmpdir = $ENV{TMP} || $ENV{TMPDIR} || '/tmp';
27 if (eval {require File::Spec::Functions}) {
28 File::Spec::Functions->import();
30 *catfile = sub { join '/', @_ };
32 $file = catfile($tmpdir, "md$$");
33 @files = ($file, "$file.db", "$file.dir", "$file.pag");
35 my @present = grep -e, @files;
36 if (@present && (@failed = grep { not unlink } @present)) {
37 warn "Can't unlink @failed! ($!)";
42 tryout('Memoize::AnyDBM_File', $file, 1); # Test 1..4
43 # tryout('DB_File', $file, 1); # Test 1..4
44 unlink $file, "$file.dir", "$file.pag";
47 my ($tiepack, $file, $testno) = @_;
51 SCALAR_CACHE => ['TIE', $tiepack, $file, O_RDWR | O_CREAT, 0666],
57 print (($t1 == 5) ? "ok $testno\n" : "not ok $testno\n");
59 print (($t2 == 5) ? "ok $testno\n" : "not ok $testno\n");
62 # Now something tricky---we'll memoize c23 with the wrong table that
63 # has the 5 already cached.
65 SCALAR_CACHE => ['TIE', $tiepack, $file, O_RDWR, 0666],
72 print (($t3 == 5) ? "ok $testno\n" : "not ok $testno # Result $t3\n");
74 print (($t4 == 5) ? "ok $testno\n" : "not ok $testno # Result $t4\n");
79 my @present = grep -e, @files;
80 if (@present && (@failed = grep { not unlink } @present)) {
81 warn "Can't unlink @failed! ($!)";