PDA

View Full Version : Email::valid


skipion
10-11-2005, 11:34 AM
I'm trying to make use of email::valid. Since my host (hypermart) doesnt support this module i download it from cpan.org, and placed it in my cgi-bin directory under the name: valid.pm. The script below runs fine, but for some reason, he sees all (as far as i've tested) email as invalid. how come ?

#!/usr/bin/perl
print "Content-type:text/html\n\n";
use CGI;
require "Valid.pm";
$q=new CGI;

$senderemail="cooldaddy@wanadoo.nl";

$result=(Email::Valid->address($senderemail) ? 'yes' : 'no');

if ($result eq "yes")
{
print "Valid Email Address";
}
else
{
print "Invalid Email Address";
}

FishMonger
10-11-2005, 03:13 PM
If you redirect the error messages you'll see that your script can't find the module because you haven't told it where to find it. You should put you module(s) outside of your cgi-bin directory.

http://www.devdaily.com/perl/edu/articles/pl010015/
#!/usr/bin/perl -w

use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
use lib "/path/to/your/modules";
use Email::Valid;

my $q = new CGI;

print $q->header;
warningsToBrowser(1);

my $senderemail = "cooldaddy@wanadoo.nl";

my $result = (Email::Valid->address($senderemail) ? 'yes' : 'no');

($result eq "yes") ? print "Valid Email Address" : print "Invalid Email Address";
edit: I edited this several times because I keep seeing or not seeing things that I should have included.

skipion
10-11-2005, 04:31 PM
Thanks Fishmonger..