我在 2000 年聊天板上引用的 PerlFaq 中发现了这条智慧。
Is there a leak/bug in glob()?
Due to the current implementation on some operating systems, when you use the glob() function or its angle-bracket alias in a scalar context, you may cause a leak and/or unpredictable behavior. It's best therefore to use glob() only in list context.
我读到这个问题已在 Perl 5.6 中修复,但后来听说它仍然出现在 5.10.1 中
有没有人对最近的问题有任何经验,在哪里可以找到有关此问题的明确答案的最佳位置?
[稍后..] 最新的 PerlFAQ 说:
5.18: Is there a leak/bug in glob()?
(contributed by brian d foy)
Starting with Perl 5.6.0, "glob" is implemented internally rather than relying on an external resource. As such, memory issues with "glob" aren't a problem in modern perls.
======
最后:报告的问题是由于在 glob 已经给出所有匹配项后在循环中使用它而滥用它。没有问题。
最佳答案
使用 Source Luke 和 Commit History
http://perl5.git.perl.org/perl.git/history/HEAD:/ext/File-Glob
更新:虽然那个长期过时的 perlfaq5 项目存在于 5.14 中它在 latest 中消失了
关于perl - perl 中的 glob() 是否仍然存在不可预测的行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12815091/