<?xml version="1.0" encoding="windows-1252"?>
<node id="996672" title="Search array of file names in directory structure" created="2012-10-01 10:59:27" updated="2012-10-01 10:59:27">
<type id="115">
perlquestion</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
Hi Monks!&lt;br&gt;

I having an issue where I am trying to search in this directory structure for all html files that will match against
a list of file names in an array(@filelist). I am finding all the HTMLs fine using  "File::Find::Rule"  searching recursively,
but my issue is finding the best way to get only the file names that match in the @filelist array into the @found_html array in my code.
Literally using the names in the @filelist array to search for them in the directory($dir) and place the found file names in the @found_html.&lt;br&gt;&lt;br&gt;
Thanks for looking!!!
&lt;br&gt;
&lt;code&gt;
#!/usr/bin/perl -w

use strict;
use File::Find::Rule;
use File::Basename;


my @filelist = qw(1234567_3a_20101000.html  99877_b_20111111.html 99877_c_20111111.html 99877_d_20111111.html 99877_e_20111111.html 99877_uf_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 99877_rr_20111111.html 99877_sx_20111111.html 99877_xy_20111111.html 99877_nm_20111111.html); 


my $dir = '/var/www/files/';

my $find = File::Find::Rule
  -&gt;file
  -&gt;name(qr/\.html?$/)
  -&gt;start( $dir );

my $f_count = 0;

my @found_html;

while ( defined ( my $html_document = $find-&gt;match ) ) {
   $f_count++;

    my $filenames = basename( $html_document );

    foreach my $chk_file(@filelist) {

      if($chk_file=~/$filenames/g) {     
      push @found_html, $filenames;
     }
     
    }
   
}
&lt;/code&gt;</field>
<field name="reputation">
4</field>
</data>
</node>
