Find the array containing string and copy the file to other folder extactly

use strict; use warnings; use File::Copy; use File::Find::Rule; use File::Find; use File::Basename; my $source_dir = "<Sorce Directory with specific files>"; my @doc=File::Find::Rule->file->name('*.xml')->in($source_dir); my $path="<parent folder>"; my @folders; find sub{ push @folders, "$File::Find::name" if (-d $File::Find::name); },$path; foreach my $fileformat (@doc){ my $baseFile=basename ($fileformat); $baseFile=~s/\.xml//isg;###handled xml for sake my @results = grep /$baseFile/, @folders; copy ($fileformat,@results); ###copied files to destination and ma +tched }