Perl 为什么不能从File::Spec导入单个函数?

Perl 为什么不能从File::Spec导入单个函数?,perl,Perl,考虑: use File::Spec qw(catfile); use File::Copy qw(copy); catfile("a","b"); copy("a","b"); 这会产生错误: Undefined subroutine &main::catfile called 我知道我可以使用File::Spec::Functions,但这会从File::Spec导入所有函数,这不是我想要的。您可以使用 use File::Spec::Functions qw{ catfil

考虑:

use File::Spec qw(catfile);
use File::Copy qw(copy);

catfile("a","b");
copy("a","b");
这会产生错误:

Undefined subroutine &main::catfile called 
我知道我可以使用File::Spec::Functions,但这会从File::Spec导入所有函数,这不是我想要的。

您可以使用

use File::Spec::Functions qw{ catfile };
它不适用于File::Spec的原因是该模块是面向对象的。所有函数实际上都是类方法