如何在Perl中打开多个文件夹并比较文件?
我有一个如何在Perl中打开多个文件夹并比较文件?,perl,Perl,我有一个父文件夹\u 1和许多子文件夹。我还有parent\u folder\u 2和许多子文件夹 子文件夹包含.d文件 我必须获得用户想要比较的父文件夹的数量 例如: “要比较多少父文件夹?” 如果用户输入4,那么脚本应该询问所有四个父文件夹的路径 在一个父文件夹中,在一个子文件夹中,还有另一个名为d folder的文件夹,其中包含.d文件 我必须比较所有四个父文件夹中的每个.d文件,并将结果放入Excel电子表格中,以确定哪些父文件夹中存在哪些.d文件 如果父文件夹1和父文件夹3中存在xxx
父文件夹\u 1
和许多子文件夹。我还有parent\u folder\u 2
和许多子文件夹
子文件夹包含.d文件
我必须获得用户想要比较的父文件夹的数量
例如:
“要比较多少父文件夹?”
如果用户输入4,那么脚本应该询问所有四个父文件夹的路径
在一个父文件夹中,在一个子文件夹中,还有另一个名为d folder
的文件夹,其中包含.d文件
我必须比较所有四个父文件夹中的每个.d文件,并将结果放入Excel电子表格中,以确定哪些父文件夹中存在哪些.d文件
如果父文件夹1和父文件夹3中存在xxx.d sf,则输出应为:
xxx.d parent folder1 #this space is for parent folder2 if present# parentfolder3
这就是想法:
- 用于遍历目录、子目录和文件
- 在
通缉()
-f$File::Find::name&&$File::Find::name=~/^.+\.d$/
- 如果上述条件评估为false,则返回;否则,比较文件并填充电子表格
这是一个想法:
- 用于遍历目录、子目录和文件
- 在
通缉()
-f$File::Find::name&&$File::Find::name=~/^.+\.d$/
- 如果上述条件评估为false,则返回;否则,比较文件并填充电子表格
您可以尝试使用
#opening the directory
opendir (DIR, $directory) or die $!;
#reading the directory
while (my $file = readdir(DIR)) {
print $file;}
#thus the giving the accessing the file in the way u would like to.
你可以尝试使用
#opening the directory
opendir (DIR, $directory) or die $!;
#reading the directory
while (my $file = readdir(DIR)) {
print $file;}
#thus the giving the accessing the file in the way u would like to.