in reply to Search array of file names in directory structure
Try using the following to create an alternation regex for your name rule:
my $regex = join '|', map "\Q$_\E?", @filelist; my $find = File::Find::Rule ->file ->name(qr/^(?:$regex)$/) ->start( $dir ); while ( defined( my $html_document = $find->match ) ) { push @found_html, $html_document; } $f_count = scalar @found_html;
The generated regex:
1234567_3a_20101000\.html?|99877_b_20111111\.html?|99877_c_20111111\.h +tml?|99877_d_20111111\.html?|99877_e_20111111\.html?|99877_uf_2011111 +1\.html?|1234567_g_20101000\.html?|99877_h_20111111\.html?|99877_i_20 +111111\.html?|99877_j_20111111\.html?|99877_k_20111111\.html?|99877_l +l_20111111\.html?|1234567_pl_20101000\.html?|99877_qa_20111111\.html? +|99877_rr_20111111\.html?|99877_sx_20111111\.html?|99877_xy_20111111\ +.html?|99877_nm_20111111\.html?
Since you've established a regex name rule, you don't need to check the results of $find->match, as it's using that rule.
Edit: Have updated the regex, based upon kennethk's comments.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Search array of file names in directory structure
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 | |
|
Re^2: Search array of file names in directory structure
by Anonymous Monk on Oct 02, 2012 at 15:41 UTC | |
by Kenosis (Priest) on Oct 02, 2012 at 16:05 UTC |