http://www.perlmonks.org?node_id=459306

Q&A > hashes > How do I test the deep equality of two hash tables? - Answer contributed by cmeyer

Another way to compare to arbitrarily complex data structures is to use canonical serialization. Storable is one module that provides this capability.

For example:

use Storable; sub deeply_equal { my ( $a_ref, $b_ref ) = @_; local $Storable::canonical = 1; return Storable::freeze( $a_ref ) eq Storable::freeze( $b_ref ); }