I think most of the other posts catch speed issues. I have a couple of things I wanted to suggest though:
- use CGI or die;
- use strict and warnings
- The code print "Content-type: text/html \n\n fork failed: $!" unless defined $pid; could be re-written using CGI::Carp simply as: die "fork failed: $!" unless defined $pid;
- The code open(LIST,"$in{'list_dir'}/$in{'list'}/$in{'list'}.txt"); introduces some very serious security issues. Use taint-checking (-T), read perlsec and maybe skim through Sanitizing user-provided path/filenames. I could pass "|/bin/rm -rf " as 'list_dir' and you would be hurting the next day.
- Similarly, this is just as alarming: open (MAIL, "|$in{'mailprog'} -t");. Anyone can pass whatever command in 'mailprog' they want. You'd do better to specify this as a constant towards the top of your script.
Never trust the browser. Hope this helps.