open my $handle, '-|', $application, @args or confess "can't launch '$application': $!"; while (<$handle>){ # do something here } close $handle or warn "Errors while closing pipe to '$application': $!";