On 11/23/05, Jeremy Kister <[EMAIL PROTECTED]> wrote:
> On 11/23/2005 2:26 AM, David Gilden wrote:
> > $SendersEmail ="[EMAIL PROTECTED]";
> >
> > ($SendersEmail) = $SendersEmail  =~ m/([EMAIL PROTECTED],60})/;
> [...]
> > I was expecting this: [EMAIL PROTECTED]
> > What happened to my @ sign ?
>
> you'll notice that not only is the @ missing, but '@earthlink' is missing.
>
> in your code, after you're #!/usr/bin/perl, put:
>
> use warnings;
>
> you'll see that you havent correctly quoted/escaped the @, which is a
> special character.
>
> you can either:
>
> $SendersEmail = '[EMAIL PROTECTED]';
>
> or
>
> $SendersEmail = "[EMAIL PROTECTED]';
>
> it also doesnt appear that you need m/ --- / will do fine by itself in
> this context.
>

You want to be careful with your classes here.  '@' is not a
metacharacter inside a class ([]), so '\@' matches both a literal '\'
and '@', so q/[EMAIL PROTECTED]/ will match even though it's not a
valid email address (as opposed to qq/[EMAIL PROTECTED]/, which is).

'\w' is also dependant on locale--see perllocale--and may match
non-compliant emails if the user has locale set to a language other
than english.

and finally, your regex will happily match any combination of random
nonsense that includes letters, '@' signs, backslashes, dots, or
dashes.  Consider '@@@wejfdhf-.-.-.-.-.-.-\\\\\@'.

try something more like

/([a-z](?:[a-z._-]+[a-z])[EMAIL 
PROTECTED](?:\.[a-z][a-z-][a-z]+){0,4}\.[a-z]{2,4})/i

(untested and not guarnteed typo-free)

That's not quite RFC 2822, but it should weed out anything that isn't
at least rying to be an address.

Better yet, search cpan for email validation modules. Email::Address
is a good place to start.

HTH,

-- jay
--------------------------------------------------
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.dpguru.com  http://www.engatiki.org

values of β will give rise to dom!

Reply via email to