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.


In reply to Re: `cat $myfile`; vs. open(MYHANDLE, "myfile") by graff
in thread `cat $myfile`; vs. open(MYHANDLE, "myfile") by bw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.