in reply to Gather List of Files from Text - Compare Against List of Files from Directory

It looks to me like you don't even need to get the list of files in the directory. Just use -e to check that a file in your list exists in the folder:

foreach my $file (@strings) { next unless -e $file; # ignore this file if it doesn't exist # your code here }

NB: when declaring a scalar with my, the undef is implicit, so my $scalar; is enough. But when you write an array my @array; is an empty array, but my @array = undef; is an array with one undefined element ; the size of the array is 1 instead of 0.

Replies are listed 'Best First'.
Re^2: Gather List of Files from Text - Compare Against List of Files from Directory
by Nico (Novice) on Mar 01, 2016 at 19:40 UTC

    Thank you!

    Each file is going to have different commands executed against it. Is that possible with this code? Or do I need to get a list of commands to run against each file it found?