mark3721 has asked for the wisdom of the Perl Monks concerning the following question:

I was wondering if anyone would know a easy way to change the suffix of a email address that gets pulled through LDAP. For example, have a system do a LDAP query for a user and populates the email address but the suffix is wrong on the email address. I need something that would change for example @john.com to @doe.john.com. Is there a way to do that before it gets populated in the email address. Thanks in advanced for your help.

Replies are listed 'Best First'.
Re: Modify Email Address
by stevieb (Canon) on Oct 09, 2009 at 23:16 UTC

    You need to specify what you are doing with the email address.

    Are you currently using Perl to retrieve the address from the DB? If so, show your code that retrieves it, and the code that immediately follows the retrieval. It should be trivial to change after retrieving the address, or in most cases, on the fly before it's even stored into a variable.

    If you're not using Perl and are just asking a theoretical question, you'll need to specify your intended application.

    Steve

Re: Modify Email Address
by CountZero (Bishop) on Oct 10, 2009 at 13:59 UTC
    Somehow (it doesn't matter how) you retrieve the e-mail address and you store it in a variable. Then it is no more difficult than to replace what is wrong by the right text:
    my $email = 'me@john.com'; $email =~ s/\@john.com$/\@doe.john.com/;
    Asuming of course that the "system" you are using is Perl-based.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James