in reply to How do I determine the underlying type of an Object?
I suppose you could do something like this:
sub type { my $obj = shift; return $obj->isa('HASH') ? 'HASH' : $obj->isa('ARRAY') ? 'ARRAY' : $obj->isa('SCALAR') ? 'SCALAR' : die 'Not HASH, ARRAY or SCALAR'; } print type( bless \a ), "\n"; print type( bless [a] ), "\n"; print type( bless {a=>b} ), "\n"; print type( bless \*STDOUT ), "\n\n";
If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How do I determine the underlying type of an Object?
by adrianh (Chancellor) on Apr 19, 2003 at 21:46 UTC | |
by PodMaster (Abbot) on Apr 20, 2003 at 09:28 UTC | |
by Juerd (Abbot) on Apr 20, 2003 at 11:21 UTC | |
by adrianh (Chancellor) on Apr 20, 2003 at 12:31 UTC | |
by Juerd (Abbot) on Apr 20, 2003 at 13:46 UTC | |
by dragonchild (Archbishop) on Apr 21, 2003 at 15:52 UTC | |
| |
by Coruscate (Sexton) on Apr 19, 2003 at 21:49 UTC |