[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] character classes



At 9.13 97/3/11, Monty VanEmmerik wrote:
>MAIN:
>{
>$test= "montyv\@swfla.infi.net";
>if ($test eq \w,'\@',\w) {       #THIS LINE HERE!
>print "This is an email address!\n";
>}
>else {
>print "This is not an email address!\n";
>}
>}

Read up on regular expressions in the man page (perlre) or in the section
of the Blue Camel book or in the book Mastering Regular Epxressions by
Jeffrey Friedl from O'Reilly & Asscociates.

What you MEANT to do was this:

        if ($test =~ /[A-Za-z]\@[A-Za-z]/) {}

However, what you should probably use to be thorough is the script and
regex found at:

        http://perl.com/perl/scripts/ckaddr

Verifying e-mail addresses is no trivial task at all and has been the
subject of much debate.  This script is the best attempt to date, but NO
script can verify all good e-mail addresses.

For more regex and e-mail questions, however, please consult the
comp.lang.perl.misc newsgroup directly, as this mailing list is for
MacPerl-specific discussion, and your question is about Perl in general.

#================================================================
Chris Nandor                                      pudge@pobox.com
PGP Key 1024/B76E72AD                           http://pudge.net/
Keyfingerprint = 08 24 09 0B CE 73 CA 10  1F F7 7F 13 81 80 B6 B6