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

Re: [MacPerl] character classes (fwd)



According to Paul J. Schinder:
> Monty VanEmmerik <montyv@swfla.infi.net> writes:
> }I am working on a script that double checks a scalar to make sure there is
> }an "@"
> }present.
> }Can someone help me with the correct way to do this?
> }Thanks!
> }
> }
> }MAIN:
> }{
> }$test= "montyv\@swfla.infi.net";
> }if ($test eq \w,'\@',\w) {  	 #THIS LINE HERE!
> 
> if($test =~ /\w+@\w+/) {
> 
> }print "This is an email address!\n";
> }}
> }else {
> }print "This is not an email address!\n";
> }}
> }}

Actually, if he wants to "double check" a scalar, wouldn't
he need two IF statements?  Something like the following:
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
#	First see if we have something other than letters in the e-mail string.
#	If so, then this is not a local address we are looking at.
#
	if( $test =~ /\W/ ){
		print "We have something funky in the line.\n";
#
#	Valid characters are put inside of the [].  These are "@", the ".", and "#".
#	Some other characters you might find in an e-mail address are: "!" & "&".
#	But these are because of various older versions of TCP/IP and/or because
#	the e-mail address has to be routed through another address.
#
		if( $test =~ /[\@\.\#]/ ){
			print "It's an e-mail address.\n";
			}
			else {
				print "There's some kind of a strange character in the e-mail address\n";
				}
		}
		else {
			print "This is a local address.\n";
			}
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#

Or am I missing something?  (Probably - duh....  ;-) )