normally you should use delivery rules from sendmail/qmail/postfix or whatever mta u are using,
alias receiver@localhost:target@localhost ,
remote@yourdomain.tld
and just send the email from perl script to receiver@localhost using sendmail. mta will take care of delivering the email to both addys, that if u dont mind receiving them to both
otherwise, Mail::Sender, e.g (man page, Single single part message section, a little modified):
$do_local = 0;
$sender = new Mail::Sender {smtp => 'remote domain\'s mx', from => 'you' } or die "$Mail::Sender::Error";
$sender->Open({to=>'remote_address',subject=>''}) or $do_local = 1;
#bla bla msg send
if ($do_local) {
#doit with smtp=>'local domain', to=>'local_address'
}
this will solve not only network connectivity problems but also other smtp-related errors which may appear while talking to remote smtp server. so in case of any error it will be delivered locally. the code should look a little more elegant but im too lazy

see Mail::Sender for more infos