Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: verifying serialized objects

by saucepan (Scribe)
on Dec 22, 2000 at 08:54 UTC ( [id://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 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).

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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-03-29 14:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found