Hello All,
I just have a small query. I am just curious to know if I could have this desired output.
My input file is r145_AF_FD_z_ HJ.txt
So finally my output should be
I guess prefix and suffix should be added along with the directory name. Any help or suggestion will be helpful.
I have tried this so far
Regards,
Ramesh
I just have a small query. I am just curious to know if I could have this desired output.
My input file is r145_AF_FD_z_ HJ.txt
So finally my output should be
Code:
/abc/ FD/ r145_AF_FD_abc_ HJ.txt /pqt/ FD/r145_AF_FD_ pqt_HJ.txt /sde/ FD/r145_AF_FD_ sde_HJ.txt
I have tried this so far
Code:
#!/usr/bin/perl
use strict;
use File::Path;
use File::Copy;
my @dirs = qw[ F:/usr/eg/abc/FD F:/usr/eg/pqt/FD F:/usr/eg/sde/FD];
for my $dir (@dirs) {
mkpath($dir) or die $!;
}
chomp(my $file = <>);
for my $dir (@dirs) {
my ($rename) = $dir =~ m!/(\w+)/FD$!;
copy($file, "$dir/$rename.txt") or die $!;
}
Ramesh
Comment