Entering edit mode
7.1 years ago
finddata15
•
0
I wrote the following code to copy the files from one directory to another diorectory.Now i like to remove the some directories in the destination folder wherever the file(rev.config) includes.the folder which includes rev.config those folders should be removed using perl?Help me fix it
use File::Copy qw( copy);
use File::Find::Rule qw( );
use File::Path qw( make_path );
my $input_dir = '/home/rpiasa/DMS_DEMO/project_space';
my $output_dir = '/home/rpiasa/output/project_space';
my %created;
for my $in (
File::Find::Rule
->file()
->name(qr/^[^.].*\.config$/)
->in($input_dir)
) {
my $match_file = substr($in, length($input_dir) + 1);
my ($match_dir) = $match_file =~ m{^(.*)/} ? $1 : '.';
#print $match_dir,"\n";
my $out_dir = $output_dir . '/' . $match_dir;
my $out = $output_dir . '/' . $match_file;
make_path($out_dir) if !$created{$out_dir}++;
copy($in, $out);
}