On 5 February 2014 11:16, Ethier, Michael <[email protected]> wrote:
> Hello, > > > > I need to obtain the first and last name that would be part of the > requestor's email address. > > For example, requestor email address comes in as: > > > > From: "Smith, Joe" <[email protected]> > > > > In this example I want parse out the "Joe" and "Smith" keywords and assign > them to 2 variables > > which I will use for comparison later. > > > > I am writing a RT Scrip. Is this possible to do ? > The "name" of the requestor is stored within the UsersObj in the Requestors group object for the $Ticket. You want the first UsersObj. There's no way to know if it's the name is written "Last, First" or "First Last" so you'll have to figure that out somehow. Usually a comma in a name field means "Last, First" though so the following is a decent bet. I haven't tested this code but this ought to get you close anyway. my $realname = $self->TicketObj->Requestors->UsersObj->First->RealName; # Switch things around if there's a comma in the field. $realname =~ s/(.*),\s*(.*)/$2 $1/ if $realname =~ /,/; If they have "First Last, Company" it'll come out as "ACME Inc., Jim Smith" though which might not be terrible. Worse would be "Last, First - Position" coming out as "Jim - Manager Smith" which might sound a little too familiar for business. In my opinion you'd want to just leave it as-is so if it's Last, First and they get an email addressed to them with "Dear Smith, Jim:" they'll know it's because they have it that way in their mail client. -- Landon Stewart :: [email protected] Lead Specialist, Abuse and Security Management Spécialiste principal, gestion des abus et sécurité http://iweb.com :: +1 (888) 909-4932
