Subject: | Attribute::Memoize from a "require"d module |
Date: | Fri, 12 Dec 2008 08:03:21 +1100 |
To: | bug-Attribute-Util [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
With Attribute-Util 1.03, Attribute::Handlers 0.81 and debian perl
5.10.0, the sample program and module below get an error
loading bar ...
Can't use string ("ANON") as a symbol ref while "strict refs" in use at /usr/share/perl5/Attribute/Memoize.pm line 13.
BEGIN failed--compilation aborted at bar.pm line 9.
Compilation failed in require at foo.pl line 7.
Changing foo.pl from "require bar" to "use bar" makes it run ok.
I suspect it may be the Attribute::Handlers problem with later loaded
modules (already reported). Unless Attribute::Memoize needs some extra
incantation to be able to mung new funcs at the right time.
use Attribute::Memoize;
use strict;
use warnings;
use lib '.';
print "loading bar ...\n";
require bar;
print "bar is loaded\n";
print bar::func(),"\n";
print bar::func(),"\n";
exit 0;
package bar;
use strict;
use warnings;
use Attribute::Memoize;
sub func : Memoize {
print "func runs\n";
return 123;
}
1;