我有一个使用Module::Reload::Selective加载模块的 Perl 脚本。perl 脚本或多或少看起来像这样。
#!/usr/bin/perl
use strict;
use warnings;
use Module::Reload::Selective;
&reload;
sub reload {
Module::Reload::Selective->reload(qw(myModule));
import myModule qw($reloadtime);
$reloadtime = ${myModule::reloadtime};
}
该模块如下所示:
package myModule;
use Config::General;
use Data::Dumper;
use DBI;
use HTTP::Request::Common qw { POST };
use HTTP::Headers;
use JSON::XS;
use LWP::UserAgent;
use Module::Pluggable search_path => "Bot";
use POSIX qw(strftime ceil);
# stuff here
1;
当我运行主脚本时,我得到大约 100 个这样的:
Subroutine export_fail redefined at /usr/local/share/perl/5.14.2/Carp.pm line 64.
Subroutine _cgc redefined at /usr/local/share/perl/5.14.2/Carp.pm line 66.
Subroutine longmess redefined at /usr/local/share/perl/5.14.2/Carp.pm line 72.
Subroutine shortmess redefined at /usr/local/share/perl/5.14.2/Carp.pm line 92.
Subroutine croak redefined at /usr/local/share/perl/5.14.2/Carp.pm line 100.
Subroutine confess redefined at /usr/local/share/perl/5.14.2/Carp.pm line 101.
Subroutine carp redefined at /usr/local/share/perl/5.14.2/Carp.pm line 102.
我注意到如果我注释掉模块中的一些“使用”语句,这些语句就会消失。但我需要那些。我已经到处搜索并尝试了很多东西。无济于事。