in reply to `cat $myfile`; vs. open(MYHANDLE, "myfile")

In both this post and your earlier one, you've only been showing little snippets, so I'm wondering what might be going on elsewhere in the script...

Is it possible that the file indicated by 'path_to_my_file' happens to be one that was opened for output someplace else in your script (e.g. at some point before you reach the snippet shown here)?

If so, maybe you need to make sure that the output file handle is closed first, and maybe that depends on making sure that STDIN has reached "eof" (and depending on how the script is being invoked -- whether STDIN is coming from the keyboard vs. a file or a pipe -- maybe you need to actually enter the ms-windows "eof" marker (^Z) at the keyboard in order to make that happen).

If you haven't tried redirecting STDIN from a file, or piping from some other process to your script, try that on the version that uses 'cat', and see if it hangs.

  • Comment on Re: `cat $myfile`; vs. open(MYHANDLE, "myfile")