This is not a Perl solution, but if the remote end has an ssh daemon running, you can use SSH tunneling to connect to the remote database:
ssh -fNg -L 6603:127.0.0.1:3306 remote_user@mysql.example.com
Then you connecto to localhost:6603, and the communication should get forwarded to the remote machine.
To do this transparently from Perl, I would launch ssh in the background like this:
my $ssh_pid= open("ssh -fNg -L 6603:127.0.0.1:3306 remote_user@mysql.e
+xample.com |")
or die;
my $dbh= DBI->connect("dbd:mysql...");
...
# tear down the connection
kill -9 => $ssh_pid;