There are about a million ways to do this. Some that have been coded up into frameworks and run on mod_perl include CGI::Application, Apache::PageKit, and OpenInteract. Of course we're basically just talking about a dispatch table here. No serious magic. I think CGI::MxScreen actually tries to control which states you can go to in which order.