Requesting a little Monk Mercy here... I have a program that loads all matching file names into an array, then searches each one for a string. It runs great, but it uses 6-8 parameters. I wanted to learn Hashes so I thought this would be a good use of one. I read in an ini file in the abc=123 format and load the keys and values from there. I always display a prompt "Are these parameters correct (Y/N)" So getting that far and seeing the same parms that I used to enter on the command line, I think I'm home free. No such luck. I fall down into my existing logic, and now I'm not getting any matches on my files. Can anyone see what I'm doing wrong? Supposedly this portion of the code didn't change. I did modify it a few times to test, but I always put it back. Things like the ^ in the pattern to get all files that BEGIN with the mask, or a wildcard * in the mask, versus just the 5 characters, etc.
# Open up directory for reading the filenames
if ( ! -d $directory ) { print "'$directory' is not found\n"; exit 1;
+ }
chdir $directory;
opendir DIR, "." || die "Cannot open directory $directory\n";
# Look for '$filename' files...
while ( $file = readdir DIR ) {
if ( $file =~ /^$filemask/i ) {
chomp;
push @chk_files, $file;
print "\n\t$file ";
if ($Mode =~ /D/) {chomp ($dummy = <STDIN>);} # End of Mode
} # End of IF
} # End of While
closedir DIR;
When I look in he debugger, @chk_files is empty, yet a display line shows that I'm in the correct dir and the files are passed one by one. Thanks for the help.