views:

86

answers:

2

Hi,

I have two data structures with a mix of hashes and arrays. How can I compare the two data structures and return their differences, something like perl's Test::Harness module, but I don't want to actually run a unit test. ...or is there a way to tun Test::Harness without actually running a unit test?

+4  A: 

Perl Monks says that Test::Deep, Data::Compare, and Data::Match are your friends. Those packages don't seem to be geared towards producing detailed diffs but you might be able to hack in a callback to keep track of the precise differences.

mu is too short
neither Test::Deep nor Data::Compare are geared towards producing detailed diffs - did you miss a 'not' from your second sentence?
plusplus
Right, thanks, missing "don't" added.
mu is too short
+2  A: 

Test::Deep::NoTest (from Test::Deep) might be what you are looking for, giving the functions of Test::Deep outside a test script (eq_deeply, cmp_deeply, etc). Look at using deep_diag() to see what the differences are.

Data::Compare - also gives functions returning boolean responses (rather like using cmp on the command line for files), but (from memory) is harder to return what those differences are.

I used the former most recently, probably because to get the deep_diag() details that Data::Compare didn't provide, but haven't tried parsing the response.

plusplus