SPUG: Sub Attributes
Jonathan Mark
jhmark at xenops.com
Fri May 3 13:45:57 CDT 2002
On Fri, 3 May 2002, Parr, Ryan wrote:
> I am indeed using 5.6.1, but my example doesn't work. But even if it did,
> what would it do?
OK, I figured it out ... a working example is appended below.
It turns out that "invalid CODE attribute" means you are using an
attribute which is not defined.
To find whether a code attribute is defined, Perl calls
MODIFY_CODE_ATTRIBUTES (and also checks for some builtin attributes).
So I expect your Apache thing is defining MODIFY_CODE_ATTRIBUTES which
stores the information somewhere, to be used later.
This behavior is documented at this URL (with a warning saying these
features are experimental and may change).
http://www.perldoc.com/perl5.6.1/lib/attributes.html#Package-specific-Attribute-Handling
cheers,
Jonathan
package foo;
use strict;
print "now at runtime\n";
sub MODIFY_CODE_ATTRIBUTES
{
my ($package_name, $sub_ref, @attrs) = @_;
foreach my $attr (@attrs)
{
print "at compile time, sub $sub_ref has attribute $attr.\n";
}
return ();
}
sub doTest : nerf
{
print "hello\n";
};
foo->doTest();
1;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
More information about the spug-list
mailing list