If you do this as part of a test case, then you should use Test::More is_deeply , which will compare two complex data structure references together and print where they differ.
use Test::More; $a = { a => [ qw/abc/ ], b => { a => 1, b =>2 }, c => 'd' }; $b = { a => [ qw/abc/ ], b => { a => 2, b =>2 }}; is_deeply($a, $b, 'Testing data structures'); not ok 1 - Testing data structures
If you need to do this in code, then @Alan Haggai Alavi's answer is better.
andeyatz
source share