Perl Question (OT)

Julian Field mailscanner at ecs.soton.ac.uk
Fri Mar 12 09:46:23 GMT 2004


At 02:28 12/03/2004, you wrote:
>On Fri, Mar 12, 2004 at 01:07:50PM +1100, Pete is rumored to have said:
> >
> > 1. How do i strip the username and domain from an email address into
> > seperate variables?
>
>assuming that the address is in the variable $email...
>
>$email =~ /(.*)?\@(.*)/;
>$user = $1;
>$domain = $2;

($user, $domain) = split(/\@/, $email, 2);

> > 2. How do i place a . after the first char of usernmame.
>
>($firstchar,$therest) = split(//,$user,2);
>$userwithdot = "$firstchar.$therest";

$user =~ s/^(.)(.*)$/$1.$2/;

--
Julian Field
www.MailScanner.info
MailScanner thanks transtec Computers for their support

PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654



More information about the MailScanner mailing list