我有这三个文件
常量/请求.pm
#!/usr/bin/perl
use strict;
use base 'Exporter';
use constant MR_NOACTION => 0;
use constant MR_START => 1;
use constant MR_STOP => 2;
our @EXPORT = (
'MR_NOACTION',
'MR_START',
'MR_STOP'
);
1;
JobManDB.pm
#!/usr/bin/perl
package JobManDB;
use strict;
use warnings;
use constant WEB_DB_FILE => "db/web.db";
use constant MASTER_DB_FILE => "db/master.db";
use Constants::Requests;
sub new
{
print "Ahoj: " . MR_NOACTION . "\n";
...
大师.pm
#!/usr/bin/perl
package Master;
use strict;
use warnings;
use Time::HiRes qw( usleep );
use Data::Dumper;
use JobManDB; # use #1
use Constants::Requests; # use #2
...
发布的程序正在运行,但如果我use #1
使用use #2
编译失败并出现错误:
Bareword "MR_NOACTION" not allowed while "strict subs" in use at lib/JobManDB.pm line 26.
(第 26 行是“新”子程序中的行)。我想知道为什么。谢谢你。
编辑:另一个问题是,如果我package Requests;
在 Requests.pm 的开头添加一行,编译会失败并出现相同的错误,但独立于“使用”的顺序。