On Fri, 29 Aug 2003, Mark Fowler wrote:

> I'm spitting out files that I'm creating from a data structure.
> Currently these are uniquely named using Data::UUID.  It's very good at
> the task, but in some situations I need the filename to stay the same for
> each identical data structure each and every time I run my script.
> 
> Essentially what I need to do is calculate a hashkey for a Perl data
> structure.  What's the commonly accepted wisdom to do this?  My wee little

While this is possible, I think that you should reconsider your 
requirements. I'm sure you don't need a key based on your entire data 
structure, and that some smaller and well defined part or parts of it will 
serve nicely when fed through MD5.

No hashing algorithm guarantees lack of collisions, therefore the only 
difference betwen MD5'ing the entire structure, and MD5'ing the integer 
size of the base hash is the number of collisions. So just pick a key and 
live with some clashes.

S.

> brain is thinking serialisation either by Storable or YAML and then hashing
> with Digest::MD5 or one of the other common string hashing routines.  The
> only problem I see with this is things like different versions of Storable
> suddenly hashing to different values.
> 
> Ideas?
> 
> Mark.
> 
> 

-- 
Shevek                                    http://www.anarres.org/
I am the Borg.                         http://www.gothnicity.org/

Reply via email to