Main Content

Perl and CGI - simple form, and monitoring script.

Archive - Originally posted on "The Horse's Mouth" - 2011-09-17 17:47:29 - Graham Ellis

In some ways, Perl and CGI (Common Gateway Interface) is "old hat", but some times it's still just what you need.

Over the last couple of days, I've been working with Perl, with a customer for an intermediate tutorial session on some aspects of the language such as Object Orientation and Regular Expressions, and we touched on "can I send the output through to a browser too". Yes, of course, and CGI is neat and straightforward for the task; we don't need scookies, sessions, frameworks, MVC or the like - just simple displays and perhaps the odd form (and we do need to consider the web security!).

Two source code examples with links to demonstrations ...

1. A simple form which the user fills in with a height and a width. Reply gives the area, echos back inputs too. Script has "injection attack" protection to avoid use entering something silly - you need that even on the simplest of scripts. [see demo]

2. An administrator's tool to keep an eye on the server - the uptime report, disc utilisation, and the status of another server too, checked via a ping. [see demo]