gitano has asked for the wisdom of the Perl Monks concerning the following question:
Hello Perl Monks, Trying to parse an e-mail address vis:
$adr = "User@domain.com"; @ads = split(/@/,$adr);
What I was expecting was to achieve was: @ads[0]="User" @ads1="domain.com" what I get however is: @ads[0]="User.com" @ads1="" Aware that @ is a special character I tried various combinations of "\" and "@" as the split argument but alas the result is the same. As a slightly different approach I tried:
$sub = $adr; $sub =~ s/@/\@/;
but again this gave $sub = "User.com" I guess I need to change the syntax somehow to accept the "@" or try a different approach altogether. Any suggestions gratefully received.
Thanks to everyone who responded for all the help.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Parsing an email address
by Corion (Patriarch) on Oct 03, 2010 at 12:34 UTC | |
by fisher (Priest) on Oct 03, 2010 at 13:57 UTC | |
by halfcountplus (Hermit) on Oct 03, 2010 at 15:11 UTC | |
Re: Parsing an email address
by AnomalousMonk (Archbishop) on Oct 03, 2010 at 12:54 UTC | |
by Limbic~Region (Chancellor) on Oct 03, 2010 at 14:53 UTC | |
Re: Parsing an email address
by TomDLux (Vicar) on Oct 03, 2010 at 18:29 UTC |
Back to
Seekers of Perl Wisdom