3 Answers
3

Just for completeness (problem was solved as pointed out in the comment to Uri's answer) the problem arose because the for expression evaluates the <> operator in list context (see), equivalently to the following:

foreach $line (@lines = <PIPE>) {
print $line;
}

In list context, the <> operator tries to read all lines from its input to asign to the list - and the input comes from a process, it will block until the process ends. Only afterwards it it will enter the loop body.

The alternative syntax

while( <PIPE> ) {
print;
}

is equivalent instead to

while( $line = <PIPE> ) {
print $line;
}

i.e., it consumes each line from the input in each loop iteration, and this is what one wants to do in this scenario.

Buffering is probably the issue, but the problematic buffer is on Ant's side, not Perl's. You only need to turn off buffering on output pipes, not input pipes. You'll need to find some way to tell Ant not to buffer its output. You can't fix the problem on the Perl side.
–
cjmMay 23 '10 at 21:00