gpt4 book ai didi

perl - 为什么无法从 File::Spec 导入单个函数?

转载 作者:行者123 更新时间:2023-12-01 04:44:51 25 4
gpt4 key购买 nike

考虑:

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

catfile("a","b");
copy("a","b");

给出错误:

Undefined subroutine &main::catfile called 

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

最佳答案

你可以使用

use File::Spec::Functions qw{ catfile };

它对 File::Spec 不起作用的原因是该模块是面向对象的。所有函数实际上都是类方法。

关于perl - 为什么无法从 File::Spec 导入单个函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23287572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com