in reply to First Perl CGI app; desirous of peer review.

Regarding the SQL query in duplicate_email(), unless there's a compelling need to return anything more than true or false, I'd change it to SELECT COUNT(*) FROM email WHERE email='$email'. Why make the database do more work than it needs, especially if you're returning the parameter you passed in if there are duplicates. :) (Hey, this isn't a big inefficiency unless you have an oustandingly large number of rows to return, but it's a good principle.)

Regarding Masem's suggestion for a dispatch table, instead of changing the function signatures for all of your subroutines, you can use anonymous subs:

my %functions = ( default => sub { write_default($script_loc) }, warning => sub { write_warning($script_loc, $email, $name, $warnin +g_msg) }, confirm => sub { write_confirm($script_loc, $email, $name) }, commit => sub { write_commit($email, $name) }, );
Ahh, closures.

Update: mischief caught a missing curly brace.

Replies are listed 'Best First'.
Re: Re: First Perl CGI app; desirous of peer review.
by legLess (Hermit) on Jun 24, 2001 at 22:16 UTC
    Thanks chromatic. You're right - count() is a much better way to do this. I don't totally understand Masem's suggestion, and yours is way over my head right now, but I'll understand 'em both by the end of the day.
    --
    man with no legs, inc.