foreach my $chk_file(@filelist) { #if($chk_file=~/$f_name/) { if($f_name=~/$chk_file/) { print "$c - Found and to be deleted: $files\n"; } }