Apparently introspection isn't part of the API

see attributes, Attribute::Handlers

#!/usr/bin/perl -- package Foo; BEGIN { use Scalar::Util qw( refaddr ); our %attrs; sub MODIFY_SCALAR_ATTRIBUTES { print "Foo::MODIFY_SCALAR_ATTRIBUTES! @_\n"; my($package, $scalarref, @attrs) = @_; $attrs{ refaddr $scalarref } = \@attrs; return; } sub FETCH_SCALAR_ATTRIBUTES { print "Foo::FETCH_SCALAR_ATTRIBUTES! @_\n"; my($package, $scalarref) = @_; my $attrs = $attrs{ refaddr $scalarref }; return $attrs ? @$attrs : (); } sub new { print "Foo::new! @_\n"; my $class = shift; return bless { yo => [@_] }, $class ; } } use strict; use warnings; use attributes(); use Data::Dump; my Foo $bar : WHAT = 24; my Foo $ey = 42; my Foo $new :AND :CHEWY = Foo->new( 42 ); print "\n\n"; for my $ref( \$bar, \$ey, \$new ){ dd $ref; dd [ attributes::get($ref) ]; dd [ attributes::_fetch_attrs($ref) ]; #~ use Devel::Peek;Dump( $ref ); print "\n\n"; } dd \%Foo::attrs; __END__ Foo::MODIFY_SCALAR_ATTRIBUTES! Foo SCALAR(0x9c8284) WHAT Foo::new! Foo 42 Foo::MODIFY_SCALAR_ATTRIBUTES! Foo SCALAR(0xa3358c) AND CHEWY \24 Foo::FETCH_SCALAR_ATTRIBUTES! Foo SCALAR(0x9c8284) ["WHAT"] [] \42 Foo::FETCH_SCALAR_ATTRIBUTES! Foo SCALAR(0x99aa3c) [] [] \bless({ yo => [42] }, "Foo") [] [] { 10257028 => ["WHAT"], 10696076 => ["AND", "CHEWY"] }

In reply to Re: Detecting declaration type? by Anonymous Monk
in thread Detecting declaration type? by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.