in reply to
Open file for output errors
The open wouldn't fail because of intended output. My guess is there is a problem with your file specification. Are you sure you're getting a legal file name? Since Perl is agnostic to forward/backward slashes in paths on Windows, what happens when you change your open statement to:
open $OFH, ">", "$directory_name/$output_file_name"
or die "Could not open output file: $directory_name/$o
I suppose it might also be related to your odd filehandle scoping, but Perl should be handling that cleanly.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.