in reply to How to differentiate hash reference and object reference?
ref EXPRSo, there's no need to call ->isa():
ref
Returns a true value if EXPR is a reference, false otherwise. If EXPR is not specified, $_ will be used. The value returned depends on the type of thing the reference is a reference to. Builtin types include:
SCALAR
ARRAY
HASH
CODE
REF
GLOB
LVALUE
If the referenced object has been blessed into a package, then that package name is returned instead. You can think of ref as a typeof operator.
(untested)sub wants_foo_object { my $obj = shift; die unless $obj && ref($obj) eq "foo"; #... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to differentiate hash reference and object reference?
by phaylon (Curate) on Aug 31, 2005 at 12:51 UTC | |
by chromatic (Archbishop) on Aug 31, 2005 at 17:21 UTC | |
by phaylon (Curate) on Aug 31, 2005 at 20:08 UTC |