in reply to Net::OpenSSH multiple commands

Ideally, you should be able to run commands sequentially:
my $output1 = $ssh->capture('sh run'); my $output2 = $ssh->capture('sh ver');

Unfortunately, some devices do not support this mode of operation and force you to talk to some kind of custom shell.

In that case, in order to start a remote shell from Net::OpenSSH, call open2pty without passing any command:

my ($pty, $pid) = $ssh->open2pty;

...and then, use Expect to talk to the shell.

Sometimes the following approach also works:

my $output = $ssh->capture({stdin_data => "ssh ver\nexit\n"})

See also the FAQ section from the module docs.