http://qs1969.pair.com?node_id=48008


in reply to verifying serialized objects

What kinds of problems are you worried about detecting? I/O errors? Data::Dumper doesn't seem to do any I/O, so you should be fine as long as you are careful to do the error checking yourself when writing to disk (remember that both close and print have return values; see Fatal.pm for a way to reduce the workload a bit).

Storable's man page promises that it checks for I/O errors. I just checked this by creating a small RAM disk and running the following script:

#!/usr/bin/perl use Storable; my @huge = ('aaaaa' .. 'azaaa'); my $result = undef; eval { $result = store \@huge, '/mnt/mfs/bigfile' }; $result = '(undef)' unless defined $result; print "Result:$result exception:$@\n";
Sure enough, this displayed "Result:1" unless the RAM disk filled up, in which cases it displayed "Result:(undef)". (As an aside, the man page says store will die on "serious" errors, but I wasn't able to induce this even by forcibly unmounting the filesystem in mid-write... whatever these serious errors are, I hope I never see one! :)

If you are really paranoid (or running NFS with UDP checksums disabled), you could always try thawing your data back into a second variable and then either doing your own deep comparison or letting Storable do it for you (look for the $Storable::canonical option in the Storable man page).