use overload '%{}'=>sub{{}}; sub new { bless [] } $ref = new(); eval { keys %$ref } ; print "is it a hash?" unless $@;