use Net::OpenSSH; my $ssh = Net::OpenSSH->new($host); die $ssh->error if $ssh->error; $ssh->system({ssh_opts => ['-O','forward', '-L127.0.0.1:12345:127.0.0.1:3306' ] }) or die $ssh->error;