belg4mit posted a regex that would swap submit HTML into a button with a JS function call. I'm not dealing directly with HTML except in the template for HTML::Template, though. (Nothing against belg4mit, because I was very vague about this all in the last post.)
No more vagaries; I'm going to lay it out here.
The script uses the state mechanism from the Cookbook (a hash associating names of states to subrefs for those states). State is determined by another sub, which checks for a valid password, valid session, and what state was desired; if the state desired requires a valid user, and there's no valid user, it defaults.
The code is all handled with short subs that I call CGI from; that code is called from the state sub and sometimes from the specific state subs themselves.
I've tried to get to the point that I don't have to call CGI directly any more, and I've pretty much succeeded. (I was using CGI for quick debugging, printing a header and some variable's contents, but I've actually written in specific debug routines and a section of the HTML::Template calls specifically produce debug info at the end of the generated page.)
I'll look at it again after a cup of strong tea. I was hoping to create a single simple JS call (the ONSUBMIT="") so I wouldn't have to go digging around in this crap again, but it looks like that may be too limited. belg's solution may be the right one: JS calls for individual submit functions.
Then again, perhaps I just haven't had enough caffeine. I'll look at all this again with a strong cup of tea by my side, and report if something significant crops up (like actual coding).