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; use File::Basename; my @filelist = qw(1234567_3a_20101000.html 99877_b_20111111.html 9987 +7_c_20111111.html 99877_d_20111111.html 99877_e_20111111.html 99877_u +f_20111111.html 1234567_g_20101000.html 99877_h_20111111.html 99877 +_i_20111111.html 99877_j_20111111.html 99877_k_20111111.html 99877_ll +_20111111.html 1234567_pl_20101000.html 99877_qa_20111111.html 998 +77_rr_20111111.html 99877_sx_20111111.html 99877_xy_20111111.html 998 +77_nm_20111111.html); my $dir = '/var/www/files/'; my $find = File::Find::Rule ->file ->name(qr/\.html?$/) ->start( $dir ); my $f_count = 0; my @found_html; while ( defined ( my $html_document = $find->match ) ) { $f_count++; my $filenames = basename( $html_document ); foreach my $chk_file(@filelist) { if($chk_file=~/$filenames/g) { push @found_html, $filenames; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Search array of file names in directory structure
by kennethk (Abbot) on Oct 01, 2012 at 15:23 UTC | |
|
Re: Search array of file names in directory structure
by Kenosis (Priest) on Oct 01, 2012 at 15:52 UTC | |
by kennethk (Abbot) on Oct 01, 2012 at 17:34 UTC | |
by Kenosis (Priest) on Oct 01, 2012 at 18:56 UTC | |
by kennethk (Abbot) on Oct 01, 2012 at 20:09 UTC | |
by Kenosis (Priest) on Oct 01, 2012 at 20:23 UTC | |
by Anonymous Monk on Oct 02, 2012 at 15:41 UTC | |
by Kenosis (Priest) on Oct 02, 2012 at 16:05 UTC |