如何使用Perl变量读取目录和子目录? [英] How to read the directories and sub directories using Perl variable?

查看:130
本文介绍了如何使用Perl变量读取目录和子目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码如何从文本文件中读取内容并使用perl检查目录和子目录名称是否存在。



注意: result_file.txt有contents.Each内容表示当前位置的目录/子目录。



我尝试过:



I have the below code how can i read the contents from the text file and check with directories and sub directories names exists or not using perl.

Note:result_file.txt has contents.Each contents denotes the directories/subdirectories in the current location.

What I have tried:

<pre>open( my $fh2, '<', "result_file.txt" ) || die( $! ))
{
while ( my $row = <$fh2> ) {
	chomp $row;
	my $dir = $row;
      print $dir,"\n";
	#print "****$row****";
}
close($fh2);
}

推荐答案

fh2,'<',result_file.txt)||死(
fh2, '<', "result_file.txt" ) || die(


!))
{
while(my
! )) { while ( my


row =<
row = <


这篇关于如何使用Perl变量读取目录和子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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