如何遍历 Perl 目录中的文件? [英] How can I loop through files in a directory in Perl?

查看:21
本文介绍了如何遍历 Perl 目录中的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
如何列出所有Perl 目录中的文件?

我想遍历所有包含在同一目录中的几百个文件.我将如何在 Perl 中执行此操作?

I want to loop through a few hundred files that are all contained in the same directory. How would I do this in Perl?

推荐答案

#!/usr/bin/perl -w

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

哪里

 @files = <*>;

可以

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

这篇关于如何遍历 Perl 目录中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆