in reply to Checking files in a directory

From the top of my head (since I can't see the code you're using to create the array of file_names_to_match -- which may be at the root of your problem):

  1. you have a chomp at line 9 that should probably be exercised whilst creating the file_names array.
  2. Have you checked the content of $filemask with a debugging print when first available? Also, is $filemask created using qr?

And, OT, unsolicited observation: your line 1 above has at least one problem: the single quotes around $directory in your homebrew error message will prevent Perl from interpolating the var. You may wish to use a more canonical form of the (wise!) attempt to check your conditional:

if ( ! -d $directory ) { die "No such \$directory, $directory: $!"; }

Replies are listed 'Best First'.
Re^2: Checking files in a directory
by AnomalousMonk (Archbishop) on Apr 20, 2011 at 04:41 UTC
    ... problem: the single quotes around  $directory in your homebrew error message will prevent Perl from interpolating the var.

    Not so. The scalar is interpolated within double-quotes; the single-quotes in the same string have no effect on interpolation.

    >perl -wMstrict -le "my $string = 'hi there'; my $strung = qq{'$string'}; print $strung; " 'hi there'