I'm working on a module that will allow a developer to write "Classes" in Perl. Then, the developer will be able to call methods in those classes from either the command line, cgi, web sockets, stand-alone web servicer, or from native Perl. The classes will be self documenting and will benefit from parameter type-checking. My module will allow the developer to specify both the input and output data format, such as text, csv, html, json, xml, Perl hash, etc. Finally, configuration/authentication information can be segregated from the main code and perhaps even stored outside of the normal web-space.
So, you would be able to create an Object Class Module and be able to call those methods from the command line during testing. Then you could deploy the same code via cgi for your web applications. At scale, this same code would be available via a stand-alone server.
During testing, you could supply the data via xml and get the results in json, if you wanted.