This worked for me:
#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH::Expect;
my $ssh = Net::SSH::Expect->new(
host => 'localhost',
user => 'someuser',
password => 'somepassword'
);
warn "Starting SSH...";
$ssh->run_ssh();
warn "Testing login output...";
my $login_output = $ssh->login();
print " Done", "\n";
my $who = $ssh->exec('who');
print($who);
my $exp = 'who';
$exp = $ssh->get_expect();
$exp->interact();
I guess that my system works fine without disabling the terminal. It may or may not work for you.