in reply to FIle name help!
For starters, you're opening the file '$control_file' before assigning anything to that variable, so it's empty. If you 'use warnings', it'll tell you about that. Plus, since you've got single quotes inside double quotes, you actually get a file named with two single quotes. Probably not what you want.
Because you open the control file outside your loop, I'm not sure whether you want a single file containing a list of names created from all your PDF files (what your code seems designed to try to do), or a different control file to match each PDF (what your description sounds like). Can you clarify?
Edited to add: Upon re-reading, it appears that you want a single control file, named after the "first" file found in the directories. (Whether you want the first one alphabetically, or by age, or by some other sorting factor, I don't know, so I'll just assume whichever one read_dir() returns first will do.) In that case, use $acc_files[0] for your control file name, after changing the suffix:
($control_file = $acc_files[0]) =~ s/pdf$/txt/;
|
|---|