in reply to RE: Answer: How do I test if a
in thread How do I test if a 'thing' is a hash (or array or scalar)?
To be clear, you are suggesting something like:
or$ref =~ /HASH/
which checks the "stringification" of the reference. But this fails for objects that have stringification overloaded. It is better than ref(), but I still don't want to make code that breaks for such cases. I have seen cases of this, but unfortunately I don't remember where. :($ref =~ /(^|=)HASH\b/
If UNIVERSAL::isa() is a pig, then an efficient replacement needs to be provided (Hmmm... that would be an easy XS to write...).
I didn't think that UNIVERSAL::isa() would search the inheritance tree since whether a blessed reference is a hash or not has nothing to do with inheritance. I hadn't looked into how isa() is implemented. You'll have to read universal.c if you are that interested. I started to and realized I don't have that much time right now.
- tye (but my friends call me "Tye")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: RE: Answer: How do I test if a "thing" is a hash?
by tye (Sage) on Sep 14, 2000 at 09:34 UTC |