Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-26 09:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found