How do I do a simple Perl hash equivalence compari

2019-06-16 20:46发布

I'm wondering if there's an idiomatic one-liner or a standard-distribution package/function that I can use to compare two Perl hashes with only builtin, non-blessed types. The hashes are not identical (they don't have equivalent memory addresses).

I'd like to know the answer for both for shallow hashes and hashes with nested collections, but I understand that shallow hashes may have a much simpler solution.

TIA!

8条回答
放我归山
2楼-- · 2019-06-16 21:09

You can use eq_deeply in Test::Deep::NoTest. It just returns a boolean that you can check, without the extra overhead of the testing capabilities of the main module.

查看更多
神经病院院长
3楼-- · 2019-06-16 21:11

Something like cmp_deeply available in Test::Deep ?

查看更多
登录 后发表回答