use Storable; sub identity_of { my $thing = shift; local $Storable::canonical = 1; return ref $thing ? Storable::freeze( $thing ) : $thing; }; my $array = Array::AsHash->new({ array => [ [1,2,3] => 'Ovid' ], hash_on => \&identity_of, });