If you are that concerned about module dependencies there is always the option of a copy 'n' paste of the pure perl version :-)
# from Scalar::Util sub UNIVERSAL::a_sub_not_likely_to_be_here { ref($_[0]) } sub reftype ($) { local($@, $SIG{__DIE__}, $SIG{__WARN__}); my $r = shift; my $t; length($t = ref($r)) or return undef; # This eval will fail if the reference is not blessed eval { $r->a_sub_not_likely_to_be_here; 1 } ? do { $t = eval { # we have a GLOB or an IO. Stringify a GLOB gives it's name my $q = *$r; $q =~ /^\*/ ? "GLOB" : "IO"; } or do { # OK, if we don't have a GLOB what parts of # a glob will it populate. # NOTE: A glob always has a SCALAR local *glob = $r; defined *glob{ARRAY} && "ARRAY" or defined *glob{HASH} && "HASH" or defined *glob{CODE} && "CODE" or length(ref(${$r})) ? "REF" : "SCALAR"; } } : $t }
In reply to Re^6: Report on Blessing to 'tag' an object
by adrianh
in thread Report on Blessing to 'tag' an object
by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |