perl – 使用父级’Exporter’与使用Exporter’import’;

前端之家收集整理的这篇文章主要介绍了perl – 使用父级’Exporter’与使用Exporter’import’;前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如果我使用第一个例子而不是第二个例子,我会得到什么?

package Some::Module;
use strict;
use 5.10.1;

use parent 'Exporter';
our @EXPORT_OK = qw(some_func);
package Some::Module;
use strict;
use 5.10.0;

use Exporter 'import';
our @EXPORT_OK = qw(some_func);

解决方法

真的没什么.出口商最初被设想作为基类工作;后来它被增强,允许您只导入其导入方法.现在没有理由继承它.

如果您正在编写可能与Perl 5.8.2及更早版本一起使用的代码,则应该需要足够版本的Exporter:

use Exporter 5.57 'import';

猜你在找的Perl相关文章