5 perl
我有一个类似这样的模块,在“lib”中,名为 Fool.pm,它基于CGI.pm 的源代码(因为这是我在考虑导出标签时想到的第一个模块):
package Fool;
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw/raspberry/;
%EXPORT_TAGS = (
':all' => \@EXPORT_OK,
);
1;
Run Code Online (Sandbox Code Playgroud)
和这样的测试脚本:
use lib 'lib';
use Fool qw/:all/;
Run Code Online (Sandbox Code Playgroud)
我尝试运行脚本并获得以下信息:
Run Code Online (Sandbox Code Playgroud)perl fool.pl "all" is not defined in %Fool::EXPORT_TAGS at fool.pl line 2 main::BEGIN() called at lib/Fool.pm line 2 eval {...} called at lib/Fool.pm line 2 Can't continue after import errors at fool.pl line 2 BEGIN failed--compilation aborted at fool.pl line 2.
我看不出这里有什么错误,有人可以帮忙吗?
您的密钥中不应该有冒号。另外,我认为必须声明变量our才能使其可用Exporter:
our @ISA = qw(Exporter);
our @EXPORT_OK = qw/raspberry/;
our %EXPORT_TAGS = (
'all' => \@EXPORT_OK,
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3001 次 |
| 最近记录: |