in reply to I want to professionalise my quick-and-dirty web app

CGI::Application is a venerable piece of code that has had many followers ... too many to list here.   If you search for that module-name you’ll find some of those followers, paying homage to it.   The core responsibilities of parsing a URL-string, identifying a handler, possibly loading that handler and executing it are available in many routines ... Mojolicious, for example.

My suggestion would simply be that you consider several of them:   without changing anything about your code, consider what the changes might be.   With a number-two pencil and a piece of paper, and with a wastebin nearby, start making sketches and to-do lists.

When you do get ready to make changes, then it’s definitely time to first put the whole thing under version-control, e.g. with git.   (I suggest git because it requires virtually no setup and no server; of course, it’s free, and if it’s good enough for managing the Linux Kernel it’s good enough for you.)   You can introduce the code, make one “branch” from that which represents “what you’ve got now,” then from the same root-point make other “branches” which represent your various experimentations.   You can safely and reliably now switch between them at-will.   You can, if you will, “now afford to completely screw-up”   :-)   because, well, merely checkout another branch and (presto!) you didn’t screw-up at all.   You can take the code from that or any other starting-point (one branch), make explorations in a new branch or branches, and always be able to reliably get back to precisely that starting-point.