```{index} single: reftype; attributes function ``` ```{index} single: attributes::reftype; Perl function ``` # reftype Return the underlying storage type of a reference, ignoring any class it's been blessed into. ## Synopsis ```perl use attributes 'reftype'; my $t = reftype(\@a); # 'ARRAY' my $t = reftype(bless {}, 'X'); # 'HASH' ``` ## What you get back One of `SCALAR`, `ARRAY`, `HASH`, `CODE`, `GLOB`, `IO`, `FORMAT`, `LVALUE`, or `REGEXP`. Returns `undef` when the argument is not a reference. ## Examples ```perl reftype(\1); # 'SCALAR' reftype([1, 2, 3]); # 'ARRAY' reftype(sub { }); # 'CODE' reftype(bless [], 'Foo'); # 'ARRAY' — blessing is ignored reftype(42); # undef ``` ## Edge cases - Not a reference, including `undef`: returns `undef` rather than croaking. - Called with the wrong number of args: croaks with `Usage: attributes::reftype($reference)`. ## Differences from upstream Fully compatible with upstream. In upstream `attributes.pm` this name is a typeglob alias for `builtin::reftype`; this module provides the same behaviour as a direct XS entry. ## See also - `get` — uses `reftype` to build `FETCH_${type}_ATTRIBUTES`. - `_guess_stash` — complementary helper for the "which package?" half of the same lookup.