#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;

my $email = param('email');
my $valid = 0;
print header;
print start_html("Results");

print "You entered $email, which: <br>\n";
if ($email =~ /.*\@.*/) {
   print "...matches pattern 1<br>\n";
} else { 
   print "...fails pattern 1<br>\n";
}
if ($email =~ /\S+\@\S+/) {
   print "...matches pattern 2<br>\n";
} else {
   print "...fails pattern 2<br>\n";
}
if ($email =~ /\S+\@\S+\.\S+/) {
   print "...matches pattern 3<br>\n";
} else {
   print "...fails pattern 3<br>\n";
}
if ($email =~ /[\w\-]+\@[\.\w\-]+\.[\w\-]+/) {
   print "...matches pattern 4<br>\n";
} else {
   print "...fails pattern 4<br>\n";
}
if ($email =~ /^\w+[\.\w\-]+\@[\.\w\-]+\.[\w\-]+$/) {
   print "...matches pattern 5, and appears to be a properly formed e-mail address.<br>\n";
   $valid = 1;
} else {
   print "...fails pattern 5.<br>\n";
}

unless ($valid) {
   print "This doesn't appear to be a properly formed e-mail address.<br>\n";
}

print end_html;