two hints if you decide to rewrite your app and if you want a good cgi:
use taint mode
add a apache mod_perl AND a cgi configuration, e.g.
127.0.0.1/perl/script.pl runs your script in mod_perl,
127.0.0.1/cgi-bin/script.pl in classical cgi environment.
developing in cgi has some advantages (you see performance problems better, you don't have to restart apache) but you also should test mod_perl regulary.