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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |