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

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

问题描述

可能重复:
如何列出所有使用Perl将文件放在目录中?

Possible Duplicate:
How can I list all of the files in a directory with 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 . "\n";
}

哪里

 @files = <*>;

可以

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

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

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