dist/Attribute-Handlers/demo/demo_chain.pl
raw| 1 | #! /usr/local/bin/perl -w |
| 2 | |
| 3 | use Attribute::Handlers; |
| 4 | |
| 5 | sub Prefix : ATTR { |
| 6 | my ($glob, $sub) = @_[1,2]; |
| 7 | no warnings 'redefine'; |
| 8 | *$glob = sub { |
| 9 | print "This happens first\n"; |
| 10 | $sub->(@_); |
| 11 | }; |
| 12 | } |
| 13 | |
| 14 | sub Postfix : ATTR { |
| 15 | my ($glob, $sub) = @_[1,2]; |
| 16 | no warnings 'redefine'; |
| 17 | *$glob = sub { |
| 18 | $sub->(@_); |
| 19 | print "This happens last\n"; |
| 20 | }; |
| 21 | } |
| 22 | |
| 23 | sub test : Postfix Prefix { |
| 24 | print "Hello World\n"; |
| 25 | } |
| 26 | |
| 27 | test(); |