#!/usr/bin/perl -T
# RFC 1035 3.3.13
# http://www.faqs.org/rfcs/rfc1035.html
# The rname of a DNS SOA response gives "domain-name which specifies \
#       the mailbox of the person responsible for this zone"

use strict;
use warnings;
#use Email::Valid; if you wish

# example - "noc.example.com" is "noc@example.com"
# replace first non-escaped period with an @ symbol
&mailstrip("noc.example.com");

# and remove escapes
#&mailstrip('some\.user.example.com');

sub mailstrip {
    my $emailaddress = shift;

    # replace first non-escaped period with an @ symbol
    # my $brain->hurts();
    $emailaddress =~ s/(?<!\\)(?=\.)/\@/;
    $emailaddress =~ s/\@\./\@/;
    $emailaddress =~ s/\\(.)/$1/g;

    print "$emailaddress\n";
}

Sorry, the comment form is closed at this time.

   
© 2011 Jason Filley - SnakeLegs Suffusion theme by Sayontan Sinha