Perl - Validate an email address in one line

chris (2003-07-01 00:10:21)
2155 views
0 replies
This uses the handle Email::Validate module - which can be found on CPAN.
If you are working in a UNIX varient environment, run the following as root to install the module:
prompt> perl -e MCPAN -shell
then
cpan> install Email::Validate

The email validator script can be tested then with:

prompt> ./validate.pl name@domain.co.uk

Here's the script:
#!/usr/bin/perl
use Email::Valid;
 
$address = @ARGV[0]; print (Email::Valid->address($address) ? 'yes' : 'no');

# easy huh!!!

comment