Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Data Object compares?by perl-diddler (Chaplain) |
on Jun 06, 2018 at 20:23 UTC ( [id://1216053]=note: print w/replies, xml ) | Need Help?? |
I had a need for something similar yesterday and throw together a compare routine
that recursively walks down the structure. and returns my idea of < = or >, even though
I only needed it for determining if 2 structs were the same.
Please note, it's raw code. It works on the nested data structures I've tried it on, but I haven't developed any general test cases for it -- and am not sure if I'd want to put it on cpan and if so, where. For now, I added it to my Types::Core module, as it's comparing typed data (a tenuous reason, but with it so small, and not sure where else I'd put it...eh(?)). If you decide to use it, PLEASE tell me about any bugs/problems, so I can develop tests and upgrade the code, but I just wrote it yesterday and don't even know if I want to publish it. There may be similar modules in CPAN, but I wanted something short & sweet and this did exactly what I wanted. Takes up to 3 params: 1st two are refs to the data structures. If passed no refs, it will use '$a and $b' as starting points (global compare vars). Third param '$d' stands for debug and controls the printing of various progress messages as it goes along. Literally, I'm using to test to see if some routines internal to a program generate correct results. I.e. the code generating the routines was complicated enough, that I wanted to test it separately -- calling the routines and having them generate various data structures. I needed a way to compare structures that should be equal. It sounded like you were wanting exactly the same thing I was doing, if not, sorry for the waste of bandwidth and misunderstanding what you wanted, but if it works for you, cool! Linda
In Section
Seekers of Perl Wisdom
|
|