- or download this
my @array = (1, 2, 3);
my $aref = \@array;
showarray($aref);
...
__DATA__
ARRAY: 1 2 3
Not an ARRAY reference at reftype.pl line 14.
- or download this
use B;
sub refcheck {
my $ref = shift;
return ref(B::svref_2object($ref)) =~ /B::(\w+)/;
}
- or download this
sub reftype {
my $ref = shift;
$ref =~ s/\(.*\)$//; # get rid of the (0x0000000) portion of the ref
+erence
$ref =~ s/^.*=//; # get rid of the CLASS= portion of the referenc
+e
return $ref;
}