gpt4 book ai didi

perl - 如何在 Perl 中获取目录列表?

转载 作者:行者123 更新时间:2023-12-03 09:32:36 24 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





How do I read in the contents of a directory in Perl?

(9 个回答)


6年前关闭。




我想执行 ls在 Perl 程序中作为 CGI 脚本的一部分。为此,我使用了 exec(ls) ,但这不会从 exec 返回称呼。

有没有更好的方法来获取 Perl 中的目录列表?

最佳答案

Exec 根本不返回。如果需要,请使用系统。

如果你只是想读取一个目录,open/read/close-dir 可能更合适。

opendir my($dh), $dirname or die "Couldn't open dir '$dirname': $!";
my @files = readdir $dh;
closedir $dh;
#print files...

关于perl - 如何在 Perl 中获取目录列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/205159/

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