Hi,
i am trying to copy files of a certain type into a different directory using perl,
The copy function doesnt seem to work.
-
my @dir_list;
-
my $sub_dir;
-
my $file_name1;
-
my $file_name2;
-
my @file_list_gel;
-
my @file_list_res;
-
#--------------LINE21
-
opendir(aDIR, $dir_root);
-
@dir_list = grep !/^\.\.?$/, readdir aDIR;
-
closedir(aDIR);
-
# if .gel or .res file is found in the current directory make a copy in respective folder
-
foreach $sub_dir(@dir_list)
-
{
-
# make subdirectories in TS and results folder
-
mkdir "$dir_dest_gel\\$sub_dir" or die $!;
-
mkdir "$dir_dest_res\\$sub_dir" or die $!;
-
#------------Line 31
-
print"Sub directory :$sub_dir\n";
-
-
opendir(DIR, "$dir_root\\$sub_dir");
-
while ($_ = readdir(DIR))
-
{
-
if($_ =~ /\.gel/)
-
{
-
print"File name: $_\n";
-
print"Dest Dir: $dir_dest_gel\\$sub_dir";
-
copy("$_", "$dir_dest_gel\\$sub_dir\\$_") or die $!;
-
}
-
if($_ =~ /\.res/)
-
{
-
copy("$_", "$dir_dest_res\\$sub_dir\\$_") or die $!;
-
}
-
}
-
closedir(DIR);
-
}
-
it is printing the file name and destination directory correctly,
but copy function is not copying the file