On Thu, Jan 1, 2009 at 12:03 AM, Adam Jimerson <vend...@charter.net> wrote: > I'm trying to make my script verify a email address that a user has given to > it. I have installed and using Email::Valid but it doesn't seem to be > working for it allowed this as a email address: > > test > > The way that I have it checking is by this: > eval { > my $addr = Email::Valid->address( -address => "$email", > -mxcheck => 1); > }; >
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 -- To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org For additional commands, e-mail: beginners-cgi-h...@perl.org http://learn.perl.org/