# I may have in and out reversed here, try both ways my ($out, $in)=$ssh->open2("command and args"); close $in; while (<$out>) { # Process output } close $out;