#!/usr/bin/perl -wT use strict; use CGI; use Email::Valid; # retrieve form parameter(s) my $q = new CGI; my $tainted_email = $q->param("email"); # check that $tainted_email is valid my $is_valid = Email::Valid->address('$tainted_email'); # if $tainted_email is valid, store the address in $email my $email = ""; if ($is_valid) { $email = $tainted_email; } # grab user information my $ip_address = $ENV{REMOTE_ADDR}; my $referrer = $ENV{HTTP_REFERER}; if ($email) { # store the data in a plain text file open LOG, ">>newsletter.txt" or die "Cannot Access Logfile: $!" print LOG "$email : $ip_address : $referrer\n"; close LOG; } # print thank-you page