Just for completeness (the problem was solved, as indicated in the comment to Uri's answer), the problem arose because of the for expression, which evaluates the <> operator in the context of the list ( see ), which is equivalent to the following:
foreach $line (@lines = <PIPE>) { print $line; }
In the context of the list, the <> operator tries to read all the lines from its input to asign in the list - and the input comes from the process, it will be blocked until the process ends. Only after that he will enter the body of the cycle.
Alternative syntax
while( <PIPE> ) { print; }
equivalent instead
while( $line = <PIPE> ) { print $line; }
ie, it consumes every line from the input in each iteration of the loop, and this is what you want to do in this scenario.
leonbloy
source share