An example of Model-View-Controller techniques in a Perl / CGI script
Archive - Originally posted on "The Horse's Mouth" - 2014-11-20 16:13:17 - Graham EllisSeparating out the look and feel of a web application, the calculation logic involved therein, the standard stuff that's needed in most web applications, and the glue that holds the pieces together was become pretty standard web programming practise.
We call the look and feel the VIEW
We call the calculation logic the MODEL
We call the standard stuff that runs it all the FRAMEWORK
We call the glue holding it together the CONTROLLER
And we call the standard functions we need to do extra bits the HELPERS

Take a look at the script, projected here on the left, and you'll see the work I did on the course to show delegates where each of the elements lie in my simple script.
• the HTML at the page base is the view
• the calculation code to convert a height and weight into a BMI is the model
• the logic that takes and checks the inputs, calls the model and puts the results into a hash is the controller
• Helpers populate the view with the contents of the hash and output them
• the framework is new code that's written to wrap the other components together.
So the actual code ...
The Framework - [here]
The Model - [here]
The View - [here]
The Controller - [here]
and the Helpers [here].