3 use base Attribute::Handlers;
4 no warnings 'redefine';
7 sub Good : ATTR(SCALAR) {
8 my ($package, $symbol, $referent, $attr, $data) = @_;
10 # Invoked for any scalar variable with a :Good attribute,
11 # provided the variable was declared in MyClass (or
12 # a derived class) or typed to MyClass.
14 # Do whatever to $referent here (executed in CHECK phase).
16 print "MyClass::Good:ATTR(SCALAR)(@_);\n";
19 sub Bad : ATTR(SCALAR) {
20 # Invoked for any scalar variable with a :Bad attribute,
21 # provided the variable was declared in MyClass (or
22 # a derived class) or typed to MyClass.
24 print "MyClass::Bad:ATTR(SCALAR)(@_);\n";
27 sub Good : ATTR(ARRAY) {
28 # Invoked for any array variable with a :Good attribute,
29 # provided the variable was declared in MyClass (or
30 # a derived class) or typed to MyClass.
32 print "MyClass::Good:ATTR(ARRAY)(@_);\n";
35 sub Good : ATTR(HASH) {
36 # Invoked for any hash variable with a :Good attribute,
37 # provided the variable was declared in MyClass (or
38 # a derived class) or typed to MyClass.
40 print "MyClass::Good:ATTR(HASH)(@_);\n";
43 sub Ugly : ATTR(CODE) {
44 # Invoked for any subroutine declared in MyClass (or a
45 # derived class) with an :Ugly attribute.
47 print "MyClass::UGLY:ATTR(CODE)(@_);\n";
51 # Invoked for any scalar, array, hash, or subroutine
52 # with an :Omni attribute, provided the variable or
53 # subroutine was declared in MyClass (or a derived class)
54 # or the variable was typed to MyClass.
55 # Use ref($_[2]) to determine what kind of referent it was.
58 print "MyClass::OMNI:ATTR($type)(@_);\n";
59 use Data::Dumper 'Dumper';