Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: verifying serialized objects

by saucepan (Scribe)
on Dec 22, 2000 at 08:54 UTC ( #48008=note: print w/replies, xml ) Need Help??

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 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).

Replies are listed 'Best First'.
Re: Re: verifying serialized objects
by dshahin (Pilgrim) on Dec 28, 2000 at 01:25 UTC
    I'm not really worried about the validity of the data, so much as I want an easy way to compare to objects without having to load them into memory. That is, I just want to look at a checksum of the object, and only load the object if the checksum says it has changed. That way I can avoid strain on the network and memory, unless it is merited.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://48008]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2023-03-20 15:31 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (59 votes). Check out past polls.