in reply to Re: Report on Blessing to 'tag' an object
in thread Report on Blessing to 'tag' an object
If necessary you could use UNIVERSAL::isa() to check if the blessed ref is an array ref:
isa won't always work:
my $o = bless {}, 'ARRAY'; print "$o isa array" if UNIVERSAL::isa($o, 'ARRAY'); __END__ ARRAY=HASH(0x759c) isa array
When you want to know your implementation type you want reftype from Scalar::Util.
use Scalar::Util qw(reftype); my $hash_object = bless {}, 'ARRAY'; my $array_ref = [1,2,3]; my $array_object = bless [], 'Foo'; foreach ($hash_object, $array_ref, $array_object) { print "reftype of ", $_, " is ", reftype($_), "\n"; }; __END__ reftype of ARRAY=HASH(0x759c) is HASH reftype of ARRAY(0x7650) is ARRAY reftype of Foo=ARRAY(0x74b8) is ARRAY
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Report on Blessing to 'tag' an object
by tye (Sage) on Jan 21, 2003 at 16:44 UTC | |
by adrianh (Chancellor) on Jan 21, 2003 at 17:13 UTC | |
by John M. Dlugosz (Monsignor) on Jan 21, 2003 at 20:30 UTC | |
by adrianh (Chancellor) on Jan 21, 2003 at 20:59 UTC |