in reply to I need help with opening a directory and reading files in that directory.

Although I realize that this is a Perl training course, and that you therefore have been given a particular way to approach this task, I’d like to make one comment about this sort of task “in general.”

I really like to use file-traversal objects, such as File::Find, to navigate directory trees.   These are both cleaner and OS-indepedent, and they push the “niggling details of how to do what I want to do” out of my code.   But then, if I want to manipulate the files that I have chosen, I have learned (the hard way) to first accumulate a list of file-names into an array, then terminate the search and process the file-names that I have stashed.   Particularly in the Windows environment, there are a limited number of file-search resources and those searches can, in my experience at least, be “messed up” by doing anything that might affect the structure.   (I have even encountered oddities when merely reading the files ...)   The situation gets even more complicated if the process does not have access to every file and/or directory that it can see, and tries to do so and is denied.   So, I have learned to avoid mixing searches with anything-else.   Your Mileage May Vary.™