5 $file = "storable-testfile.$$";
6 die "Temporary file '$file' already exists" if -e $file;
8 END { while (-f $file) {unlink $file or die "Can't unlink '$file': $!" }}
10 use Storable qw (store retrieve freeze thaw nstore nfreeze);
15 open FH, "<$file" or die "Can't open '$file': $!";
18 die "Can't read $file: $!" unless defined $contents;
22 sub store_and_retrieve {
24 unlink $file or die "Can't unlink '$file': $!";
25 open FH, ">$file" or die "Can't open '$file': $!";
27 print FH $data or die "Can't print to '$file': $!";
28 close FH or die "Can't close '$file': $!";
30 return eval {retrieve $file};
35 return eval {thaw $data};