Perl 导出代码属性

Perl 导出代码属性,perl,attributes,Perl,Attributes,我想创建一个可以导入并用作代码属性的函数。 我正在使用Sub::Attribute创建属性。给出的示例使用继承,但我想导出并使用它。希望我的问题清楚 创建属性的代码段: package attpkg; use strict; use Sub::Attribute; use Exporter 'import'; our @EXPORT_OK = ('Myattr'); sub Myattr : ATTR_SUB { my ($class, $sym_ref, $code_ref, $

我想创建一个可以导入并用作代码属性的函数。 我正在使用
Sub::Attribute
创建属性。给出的示例使用继承,但我想导出并使用它。希望我的问题清楚

创建属性的代码段:

package attpkg;

use strict;
use Sub::Attribute;
use Exporter 'import';

our @EXPORT_OK = ('Myattr');

sub Myattr : ATTR_SUB {
    my ($class, $sym_ref, $code_ref, $attr_name, $attr_data) = @_;
    print "@_";
    #$code_ref->();
    print "_____________\n";
}

1;
尝试导入属性但失败的代码段:

use strict;
use attpkg qw(Myattr);

sub pHelloWorld : Myattr {
    print "Hello World\n";
}

pHelloWorld();

Sub::Attribute还会在
attpkg
命名空间中创建一个名为
MODIFY\u code\u ATTRIBUTES()
的函数。你也需要把它导出