[Mimedefang] Enumerate Email Address parts

Joseph Brennan brennan at columbia.edu
Wed Feb 3 09:27:48 EST 2010

Brian Shallenberger <brians at cleareagle.com> wrote:

> Is there a way to parse the part of the Sender's email address that
> precedes the '@' character so I can build a recipient's email address?
> For example:
> Sender email address:  Joe at abc.com

There is of course "more than one way to do it", but here's one:

my ($localpart,$domainpart) = split('@',$Sender);

Then $local is 'Joe' and $domain is 'abc.com'.

The 'my' localizes the variables to the routine that's using them.  Read
about scope in perl.  You must make sure the variables are cleared before
the next message is processed, either by scoping or by defining them to
be null before you assign to them.

Joseph Brennan
Columbia University Information Technology

More information about the MIMEDefang mailing list