http://www.perlmonks.org?node_id=223446

eoin has asked for the wisdom of the Perl Monks concerning the following question:

OK, I've gone through the code a few times and can't find the problem. Its probably some stupid mistake or other but I can't get it.
Heres the code
use strict; use diagnostics; use warnings; use CGI; my $q = new CGI; my $user_name = $q->param('user_name'); my $gender = $q->param('gender'); my $real_name = $q->param('real_name'); my $city = $q->param('city'); my $country = $q->param('country'); my $email = $q->param('email'); my $confirmemail = $q->param('confirmemail'); my $mm = $q->param('birthmm'); my $dd = $q->param('birthdd'); my $yy = $q->param('birthyy'); my ($title, $body, $i, $s, @v, @c); #--------------------------------------------------------------------- #START OF MAIN PROGRAM #--------------------------------------------------------------------- my ($password) = &password(5); my $dateofbirth = ("$dd/$mm/$yy"); my @info = ($user_name, $password, $email, $gender, $real_name, $dateo +fbirth, $city, $country); open(USRNF,"pass") or die "Couldn't find user file.\n"; if ($email ne $confirmemail){ ($title, $body) = &email_invalid();} elsif (&check_user_email($user_name,$email) eq "good"){ ($title, $body) = &good(@info);} else { ($title, $body) = &check_user_email($user_name,$email); } print qq(Content-type: text/html\n <html> <head><title>$title</title></head> $body </html>); #--------------------------------------------------------------------- #END OF MAIN PROGRAM:BEGINING OF VERIFICATION #--------------------------------------------------------------------- sub email_invalid { my $title = "Email's do not match!!"; my $body = q(<body bgcolor="black" text="red"> <h3>Your e-mail doesn't match.</h3><br><br> <h2>Please click on your browsers back button and try again.</h2></a>< +hr> </body>); return ($title, $body); } #--------------------------------------------------------------------- sub check_user_email{ while(<USRNF>){ chomp; my $user = @_; my $email = @_; my (@userinfo) = split(/\t/, $_); if ( ($userinfo[0] ne $user) && ($userinfo[2] ne $email) ){ return "good"; } elsif ( $userinfo[0] eq $user ){ my $title = "User name already in use.!"; my $body = q(<body bgcolor="black" text="red"> <h3>The username $user is already in use.</h3><br><br> <h2>Please click on your browser's back button and try a different +one.</h2></a><hr> </body>); return ($title, $body); } else { my $title = "Account already activated.!"; my $body = q(<body bgcolor="black" text="red"> <h3>Our records show that you already have a valid account.</h3><br +><br> <h2>If you wish to create another one you must first delete the old + one.<br> </h2><h3>Please email me<a href="mailto:eoinmurphy\@dubl +in.com"> here</a> to edit any account info. <hr> </body>); return ($title, $body); close(USRNF); } } #--------------------------------------------------------------------- sub good{ my @info = @_; my $title = "Registration successful!"; my $body = q(<body> <h1>Registration Confirmation</h1> <hr> <p>Dear , $real_name</p> <p>Thank you for registering with us. You have supplied us with the following information:</p> <blockquote> <p><strong>Real name:</strong>\t$real_name <br> <strong>Username:</strong>\t$user_name <br> <strong>Password:</strong>\t$password <br> <strong>E-mail:</strong>\t$email <br> <strong>Date of Birth:</strong>\t$dateofbirth <br> <strong>City:</strong>\t$city <br> <strong>Country:</strong>\t$country <br> </p> </blockquote> <p>If any of this information is incorrect, please email me <a href="mailto:eoinmurphy\@dublin.com">here</a> to change it. I reserve the right to delete any user if he\she use this account for illegal purposes.</p> <blockquote> <blockquote> <blockquote> <p>Sincerely,</p> <p><em>Webmaster, Eoin.</em></p> </blockquote> </blockquote> </blockquote> <hr> <h5>You may return to the feedback form by using the <em>Back</em> button in your browser.</h5> <h5>Revised: <!--webbot bot="TimeStamp" startspan s-type="EDITED" s-format="%B %d, %Y" -->December 31, 2002<!--webbot bot="TimeStamp" i-checksum="39470" endspan -->.</h5> </body>); open(USRNF,">>pass") or die "Couldn't find user file.\n"; printf USRNF "$info[0] $info[1] $info[2] $info[3]. $in +fo[4] $info[5] $info[6] $info[7]"; close(USRNF); return($title, $body); } sub password{ $s = @_; srand($s ^ time); @c=split(/ */, "bcdfghjklmnpqrstvwxyz"); @v=split(/ */, "aeiou"); for($i = 1; $i <= 4; $i += 1) { my $password = print $c[int(rand(20))], $v[int(rand(5))] } }}
Feel free to help..
P.s. Happy New Year - 4.

Edit by tye to add READMORE