welchavw has asked for the wisdom of the Perl Monks concerning the following question:
I have a hash of hashes that I maintain in a module that lives within a software configuration management system (ClearCase, but that is of no real import). I use the hash as a simple statistics database. A statistics collection and publishing script...
What I (think I) want is to tie *all* the hashes in the hash of hashes so that they are always retrieved sorted, so that the output from Data::Dumper is always consistent. This would, I believe, allow the output of a diff against the previous version of a module file to consistently report accurate results.
Is there any easy way to declare that all the nested hashes in a structure will be sorted? BTW, I don't care one whit about the sort comparison subs - I just want consistency in the output. I am not that familiar with this kind of problem (nor really deeply with ties). Please also note that I do want to continue to maintain the hash as an entity declared and defined purely by the text within the module, if possible. I don't want to serialize it via some external database (using Storable or some such), since doing so would prevent module version diffs from being useful.
One other question - upon an eval of the stringified (by Data::Dumper) hash will the hashes be re-tied automagically or do I have to handle that myself somehow?
Conceptual guidance will be very appreciated. I can probably figure a reasonably acceptable approach myself, but I'd like to know the best and easiest way to do this.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sort-Tying all hashes in a hash of hashes
by tcf22 (Priest) on Sep 10, 2003 at 18:41 UTC | |
|
Re: Sort-Tying all hashes in a hash of hashes
by demerphq (Chancellor) on Sep 10, 2003 at 19:29 UTC | |
|
Re: Sort-Tying all hashes in a hash of hashes
by Limbic~Region (Chancellor) on Sep 10, 2003 at 18:43 UTC | |
|
Re: Sort-Tying all hashes in a hash of hashes
by welchavw (Pilgrim) on Sep 10, 2003 at 20:17 UTC |