Dear all. I'm a novice perl user. I'm using perl to read a large amount of data but not overly large. So I'm confused why it's hanging. By hanging I mean just sitting there. The state is "S" or sometimes "R" Everywhere I read says to use while ($line = <FILE>) and I did that from the start but still not working. Here is my code:

open (FIND_OUTPUT , "$CT find . -version'brtype($branch)' -print -all +|"); # I only tried to flush the buffer because it's hanging # But still doesn't work select((select(FIND_OUTPUT), $|=1)[0]); while ($line = <FIND_OUTPUT>) { ($filename = $line) =~ s/(.*)@@.*/\1/; ($version = $line)=~ s/(.*)@@(.*)/\2/; #... do a bunch of line processing and put line in hash $ccase_filehash{$filename} .= ";" . $version; } close FIND_OUTPUT; foreach $key (keys %ccase_filehash) { print "$key: $ccase_filehash{$key} \n"; }

When that failed then I tried to write the output to a file instead. That works, the file gets written correctly and it's only 800 KB. But then it hangs either processing the file or printing out the hash

system ("$CT find $vob -version 'brtype($branch)' -print $all > /tmp/f +ind.out"); open (FIND_OUTPUT , "/tmp/find.out"); # This doesn't help but I put it in anyway select((select(FIND_OUTPUT), $|=1)[0]); while ($line = <FIND_OUTPUT>) { ($filename = $line) =~ s/(.*)@@.*/\1/; ($version = $line)=~ s/(.*)@@(.*)/\2/; #... do a bunch of line processing and put line in hash $ccase_filehash{$filename} .= ";" . $version; } foreach $key (keys %ccase_filehash) { print "$key: $ccase_filehash{$key} \n"; }

I should note that when the output of the CT command is smaller then the script doesn't hang. I also tried this without the "select" line to flush the buffer and also didn't work.


In reply to hanging script on read by Anonymous Monk

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.