Perl: Dosya ve Klasör İşlemleri

#!/usr/bin/perl -w

my $mfolder="./mainfolder/";

opendir(DIR, $mfolder) or die("Error_m1: $mfolder not opened!\n");
my @sub_folder_list=grep((!/^\./) && (-d "$mfolder/$_") ,readdir(DIR));
closedir(DIR);

foreach my $fold(@sub_folder_list)
{
	my $deepfold=$mfolder.$fold;
	
	opendir(DIR, $deepfold) or die("Error_m2: $deepfold not opened!\n");
	my @txt_files=grep(/.txt$/,readdir(DIR));
	closedir(DIR);

	foreach my $file(@txt_files)
	{
		print $deepfold."/".$file."\n";
	}

}
Share