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.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.