perl - perl 中的 glob() 是否仍然存在不可预测的行为?

标签 perl filesystems

我在 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/

相关文章:

filesystems - 如何通过 id 打开具有 DELETE 访问权限的文件?

iphone - iOS应用程序中已下载文件的磁盘空间

shell - $SIG {'ALRM' } 在 Perl 中做什么

perl - 为什么Perl的DBD::DB2在安装过程中找不到dbivport.h?

python - 编写相当于 Perl 代码的 Python 代码

c++ - 如何查看目录的子文件是否已更改

Python如何在不使用 super 用户权限的情况下创建pycache文件夹?

regex - 无法通过子例程通过正则表达式替换字符串

perl - 为什么不在 Perl 中使用严格和警告?

c++ - 使用 boost::filesystem::path 获取绝对路径