I suggest you look at CGI::Application. It sounds like it will do exactly what you're looking for, and helps you create very manageable, usable apps without getting in the way. I love it! I use it extensively in apps that work similarly to what you're describing, and I can't imagine building web applications without it and HTML::Template.
You might also check out OpenInteract by lachoy, it appears to be a very robust application framework with a good security model.
-Any sufficiently advanced technology is
indistinguishable from doubletalk.