Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use File::Find::Rule; my $startdir = "/allfiles"; my @filelist = qw(1234567_bc_20101000.txt 99877_xy_20111111.txt); #for + testing my $includeFiles = File::Find::Rule->file ->name('*.txt'); # search by file extensi +ons my @files = File::Find::Rule->or( $includeFiles ) ->in($startdir); #locate only txt files in the starting directory my $includeFiles = File::Find::Rule->file ->name('*.txt'); # search by file extensi +ons my @files = File::Find::Rule->or( $includeFiles ) ->in($startdir); my $f_name; my $c=0; foreach my $files(@files) { $c++; if($files=~/(.*?)\/([^\/]+)$/) { $f_name = $2; } foreach my $chk_file(@filelist) { if($chk_file=~/$f_name/) { print "$c - Found and to be deleted: $files\n"; } } }
|
|---|