my ($input, $output, $errput); my $subprocess = start([ '/bin/bash' ], '<', \$input, '1>pty>', \$output, '2>', \$errput); # later, for each $command { shell => 'pwd', 'outputs' => [ '/tmp/foo' ] } diag $command->{shell}; $input = $command->{shell} . "\n"; foreach my $expected_output (@{$command->{outputs}}) { while ($output !~ /\n/) { if ($errput) { diag 'STDERR: '.$errput; $errput = ''; } $subprocess->pump; } # munge $expected_output and compare stuff }