perl - 如何遍历 Perl 目录中的文件?

标签 perl file

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




11 年前关闭。




Possible Duplicate:
How can I list all of the files in a directory with Perl?



我想遍历所有包含在同一目录中的几百个文件。我将如何在 Perl 中做到这一点?

最佳答案

#!/usr/bin/perl -w

my @files = <*>;
foreach my $file (@files) {
  print $file . "\n";
}

在哪里
 @files = <*>;


 @files = </var/www/htdocs/*>;
 @files = </var/www/htdocs/*.html>;

等等。

关于perl - 如何遍历 Perl 目录中的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2149368/

相关文章:

即使文件未丢失,Perl 可执行文件也会崩溃

arrays - 如何在 Perl 中按元素求和数组?

linux - 在 Perl 中修改子进程的环境

linux - 我可以在 Linux 上识别正在进行的 Web 请求吗?

perl - 在没有Mojolicious::Lite的情况下使用 "under"进行Mojolicious基本身份验证

visual-studio - Visual Studio 2008 自动恢复目录位置更改

c - 如何从文件中读取数字并计算平均值?

c# - 文件资源管理器打开时如何修改目录时间戳?

arrays - 在 ruby​​ 文件中写入一个数组

file - 在 WSL 中运行 shell 脚本时出现 "E: Invalid operation update"错误