OPEN PIPE, "|java -jar program.jar"; open FH, /abc.txt while (my $res = ) print PIPE "$res"; close FH; close PIPE;