use base Attribute
::Handlers
;
sub Good
: ATTR
(SCALAR
) {
my ($package, $symbol, $referent, $attr, $data) = @_;
# Invoked for any scalar variable with a :Good attribute,
# provided the variable was declared in MyClass (or
# a derived class) or typed to MyClass.
# Do whatever to $referent here (executed in CHECK phase).
print "MyClass
::Good
:ATTR
(SCALAR
)(@_);\n";
# Invoked for any scalar variable with a :Bad attribute,
# provided the variable was declared in MyClass (or
# a derived class) or typed to MyClass.
print "MyClass::Bad:ATTR(SCALAR)(@_);\n";
# Invoked for any array variable with a :Good attribute,
# provided the variable was declared in MyClass (or
# a derived class) or typed to MyClass.
print "MyClass
::Good
:ATTR
(ARRAY
)(@_);\n";
# Invoked for any hash variable with a :Good attribute,
# provided the variable was declared in MyClass (or
# a derived class) or typed to MyClass.
print "MyClass::Good:ATTR(HASH)(@_);\n";
# Invoked for any subroutine declared in MyClass (or a
# derived class) with an :Ugly attribute.
print "MyClass
::UGLY
:ATTR
(CODE
)(@_);\n";
# Invoked for any scalar, array, hash, or subroutine
# with an :Omni attribute, provided the variable or
# subroutine was declared in MyClass (or a derived class)
# or the variable was typed to MyClass.
# Use ref($_[2]) to determine what kind of referent it was.
print "MyClass::OMNI:ATTR($type)(@_);\n";
use Data
::Dumper
'Dumper';