in reply to Re^3: Writing to file...
in thread Writing to file...

This glob thing is just a mess. Part of the reason is the spaces that are allowed in some Windows file systems as you have noted! Youch! I beat the doo-doo out of an Active State app trying to get glob to work. Some of the modules worked with DOS glob and some with BSD glob.  use File::Glob 'glob'; is not a magic cure all. This BSD vs Sys V thing is weirder to understand. Anyway, I've spent many hours in "glob hell" and I just don't do it anymore.

Yes, closedir is the "right thing to do"! Every file handle comes from a limited pool of system resources. For a 20 line program, I don't worry about it much, but as they say "your mileage may vary". If this 20 line thing is in a client-server app, well then an open file handle here and there adds up! And the application bombs!

I tutor some students at a local college and one fundamental mistake is lack of whitespace and separating "thought units", but you see that too!

I have ammended my evil 'C' ways in favor of lining up braces. I am quite sure that this is the best way and I don't understand why you don't think that it is.

Anyway I say Horray! The OP has some good code to work from and I think he/she will do a great job!