如何将目录内容移动到 Perl 中的数组中? [英] how to move the directory contents into an Array in Perl?
本文介绍了如何将目录内容移动到 Perl 中的数组中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要打开一个目录,读取目录中的内容/文件,我必须将目录中的所有这些文件移动到一个数组中.
I need to open a directory, read the contents/files in the directory and I've to move all those files in the directory into an array.
我必须使用 Perl 脚本来完成所有这些事情.谁能给我将目录内容移动到数组中的代码?
I have to do all these things using a Perl Script. Can anyone please give me the code to move the directory contents into an array?
请填写以下脚本:
opendir(INFILE_DIR,"$Input_Path") || die "cannot open $Input_Path ";
my @files =---------------;
------"区域将目录内容移动到数组中.
What will come at the "------" area to move the directory contents into an array.
提前致谢.
推荐答案
这不需要你chdir
到想要的目录:
This will not require you to chdir
to the wanted directory:
opendir my $dh, $dir or die "Cannot open directory $dir\n";
my @files = readdir $dh;
closedir $dh;
这篇关于如何将目录内容移动到 Perl 中的数组中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文