use Storable; $Storable::canonical = 1; my compare { Storable::freeze($_[0]) eq Storable::freeze($_[1]) }