-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mike Williams wrote: > > What are you expecting to happen? Email::Valid will throw an > exception if *it* encounters an error. > Finding an invalid address is not an error for Email::Valid. That's its job > ;-) > > $addr will be undefined if the email address is valid. > If the email address is valid $addr will contain the validated email address. > > I tried your code and it worked for me. > > You probably want to move the definition of $addr to *before* the eval > if you want to test it after the eval. Otherwise the scope of the > scalar $addr is only within brackets of the eval. > > #my $email = 'drumm...@gmail.com'; > my $email = 'test'; > my $addr; > > eval { > $addr = Email::Valid->address( -address => "$email", > -mxcheck => 1); > }; > > print "valid address ($addr)\n" if $addr; > print "Invalid address ($email)\n" unless $addr; > > Here's the output from two test runs, alternately commenting out the > two addresses above: > $ ./email_list_test.pl > valid address (drumm...@gmail.com) > $ ./email_list_test.pl > Invalid address (test) > > Happy New Year, > > Mike
Ok my problem with is was after it tests the email address I didn't use $addr, I reused $email instead. So if I change it to test to see if $addr is defined then I won't have this problem. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkleLSIACgkQRMKiLy/EUZSK6wCgqRgzzIeZAgv3z0xZX6VGpWbX Q7AAoJGhfSsEJifI7dbpKAIyFcpAwION =NMPz -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org For additional commands, e-mail: beginners-cgi-h...@perl.org http://learn.perl.org/