gpt4 book ai didi

perl - 作用域在 Perl 模块中是如何工作的?

转载 作者:行者123 更新时间:2023-12-02 05:32:07 25 4
gpt4 key购买 nike

我真的不明白作用域在 Perl 模块中是如何工作的。这不会打印任何内容。如果运行 a.pl 打印 1,我会喜欢它

下午两点

$f=1;

a.pl

use b;

print $f

最佳答案

好的,您有很多误解,我们可以通过解决您眼前的问题并为您指出好的资源来最好地解决这些问题。

b.pm 应该是:

package b;
our $f = 1;
1;

a.pl应该是

use b;
print $b::f

perl -I 运行整个程序。 a.pl

现在去阅读perldoc perlmod非常仔细。

同时阅读perldoc strict .

关于perl - 作用域在 Perl 模块中是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2822700/

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