Your approach of testing all 9000 files against your list can be made to work but there is a simpler alternative. You can use Perl's file tests to check the existence of each of the 300 files in your list given the path. If the file exists then do some function on it. In this example I'm using -e to test existence of the file.

use warnings; use strict; my $path = "path/to/folder/with/my/files"; my @list = qw( a b c d ); foreach my $file ( @list ){ print "found $file\n" if -e "$path/$file"; }

A suggestion to save yourself a lot of struggling is to start with something small and get it working before adding the next step to it. Get the part working that reads your list of 300 files first. Once you can print it back out to the console with one file per array element then check for the existence of each file and print if found. Then keep adding small steps. You wouldn't try to build a whole building at once and then fix it so why try that with a program.


In reply to Re: Parsing files in a directory using a list. by Lotus1
in thread Parsing files in a directory using a list. by oxalate

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.