use B qw( svref_2object SVt_PVHV ); sub is_hash { my $ref = shift @_; return ref( $ref ) and svref_2object( $ref ) & SVt_PVHV; }