3

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?

2 Answers 2

4

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.

1
  • neither Test::Deep nor Data::Compare are geared towards producing detailed diffs - did you miss a 'not' from your second sentence?
    – plusplus
    Oct 25, 2010 at 11:59
3

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 to get the deep_diag() details that Data::Compare didn't provide, but I haven't tried parsing the response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.