>
> You probably had $string double quoted instead of
> single quoted which later results in the \ being eaten.
>
Thank you. The people who said the problem of double quoted string are correct,
I didn't know this item before.
This is what I really want:
use strict;
my $email1 = restore_email_from_soa('support.dnsbed.com.');
my $email2 = restore_email_from_soa('dns\.support.dnsbed.com.');
my $email3 = restore_email_from_soa('dns\.tech\.support.dnsbed.com.');
print $email1,"\n";
print $email2,"\n";
print $email3,"\n";
sub restore_email_from_soa {
my $email = shift;
$email =~ s/\.$//;
if ($email =~ /^(.*?)(?<!\\)\.(.*)$/) {
my $user = $1;
my $tld = $2;
$user =~ s/\\//g;
return $user . '@'. $tld;
}
}
The output:
[email protected]
[email protected]
[email protected]
Thanks a lot!
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/