The different behaviors of windows vs. linux might involve a number of issues. First off, you're opening a compressed file for input (via the $fh file handle), but then you're treating is as if it were plain text -- you don't seem to be doing binmode on it (which would be essential for it to work properly on windows, IIRC), and you use  while (<$fh>) to read it, as if you could reasonably expect it to be a series of "lines" terminated with the standard value of $/ ($INPUT_RECORD_SEPARATOR, which of course is a bit different on windows than it is on linux). I think tye's remarks about the buffering grid lock are on the mark in your case, but I also think that the way you're handling the input has something to do with it as well.

What you might want, rather than open2 or uncompressing to a temp file, is simply something like this:

open( IN, "gzip -cd $input_file_name |" ); while (<IN>) { ... # process lines of uncompressed text }
I gather you want flexibility with different compression methods, and you would like to modularize it (give a file name to a sub, have it return a file handle for reading the uncompressed data). Both of those goals can be achieved with this sort of single-handle procedure (but I'll leave it to you to figure out how).

In reply to Re: Help!: Open2 Hangs on Windows by graff
in thread Help!: Open2 Hangs on Windows by coppit

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.