[Edinburgh-pm] Question about using attributes
Aaron Crane
perl at aaroncrane.co.uk
Tue Jun 21 14:24:46 PDT 2011
Robert Rothenberg <robrwo at gmail.com> wrote:
> I am having a strange problem with Attribute::Handlers that looks like
> some kind of bug:
> when it's called from a separate package in a separate file, "foo"
> is not called, although the compiler does accept the ":foo" attribute.
It seems to be working for me, unless I'm misunderstanding the problem:
$ head *
==> Attr.pm <==
package Attr;
use Attribute::Handlers;
sub UNIVERSAL::foo :ATTR(CODE) {
warn "applying foo attribute to ", *{ $_[1] }, "\n";
}
1;
==> Thing.pm <==
package Thing;
sub wobble :foo {}
1;
==> main.pl <==
use Attr;
use Thing;
sub wibble :foo {}
$ perl main.pl
applying foo attribute to *Thing::wobble
applying foo attribute to *main::wibble
$ perl -MAttribute::Handlers -wE 'say for $^V, Attribute::Handlers->VERSION'
v5.12.1
0.88
--
Aaron Crane ** http://aaroncrane.co.uk/
More information about the Edinburgh-pm
mailing list