kilinrax is absolutely correct about not using cgi-lib.pl. Many CGI books still recommend this library, but it is out of date and no longer being maintained. In addition to his above comments, I would strongly suggest that you use taint checking. This script does not appear to actually need it, but as you write more and more scripts, you will need it to protect the integrity of your site. See
perlsec for more details.
Your regex for testing for a valid e-mail address does not work. Below is a snippet explaining the use of Email::Valid. Email::Valid cannot catch all valid e-mail addresses as RFC822 allows for arbitrarily nested comments in e-mail addresses, but will probably correctly identify 99% or more of the e-mail addresses submitted.
#!/usr/bin/perl -wT
use strict;
use CGI;
use Email::Valid;
my $cgi = CGI-new();
my $email = $cgi->param( 'visitors_email_address' );
my $password = $cgi->param( 'visitor_password' );
my $valid_address = Email::Valid->address( $e-mail );
if ( $valid_address ) {
# Address is valid, do stuff here
# This DOES NOT mean that the address is real
} else {
# Address is invalid.
}
Additionally, I noticed that you are not consistently checking the return calls on your
open statements. If one fails to open, your script will silently continue and you won't know why.
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just go the the link and check out our stats.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.