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.