$| = 1; open(JAVA, "java_command_stuff |") or die ...; while(){ my $line = $_; print "$line
\n"; } close JAVA;