Perl and the Common Gateway Interface - out of fashion but still very useful?
Is the Common Gateway Interface dead? No - it isn't; although my first choice for a new web application these days would be something else (PHP, Java with Servlets, JSPs or a derivative, Python with Django, Ruby with Rails ...), there are often times that I'll have a bit of code that I've run away from the web and I want to run it on-line - and quickly wrapping the code with some CGI stuff will get it available fast.
With CGI, you can take code that's running in any language that your web server supports, and with careful use of the STDIN (a.k.a. pseudo keyboard inputs), environment variables, and (occasionally) command line inputs, you can feel the code with input data as if it was running from the command line. For output, you simply write your code as if you're outputting to the screen / window in a command line based application, and your web server will route that output back to the browser.
I've taken the code from my previous entry here, that looked for a Christmas *something* in all the various railway station names, and put in on line [here]
. Easy - or rather fairly
easy. In practice, there's a need to add a lot of user documentation, to take away the interaction as all data is fed in at the start, to check that the users have made sensible inputs and to secure the script against people trying to hack in to the server using it, so the code ends up a bit longer that you might have expected. See [here]
We're still covering CGI as part of our Using Perl on the Web
course ... and that's a follow on from our Perl Programming
course where you can learn the basics.
(written 2009-12-26, updated 2010-01-06)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articlesP221 - Perl on the Web 
Using CGI and Perl to put a simple application online. Sometimes still the best way. - (2012-09-30) 
From Web to Web 2 - (2007-05-21) 
Answering ALL the delegate's Perl questions - (2006-12-09) 
Presentation, Business and Persistence layers in Perl and PHP - (2006-04-17) 
An unhelpful error message from Apache httpd - (2006-03-30) 
Simple but rugged form handling demo - (2006-03-10) 
Danny and Donna are getting married - (2006-02-03) 
Running a Perl script within a PHP page - (2005-11-12) 
FTP - how to make the right transfers - (2005-09-01)P403 - Perl - The Common Gateway Interface 
Perl and CGI - simple form, and monitoring script. - (2011-09-17) 
Teaching examples in Perl - third and final part - (2010-06-27) 
Handling nasty characters - Perl, PHP, Python, Tcl, Lua - (2009-06-14) 
CGI v mod_perl - (2004-09-11)
Some other Articles
BookkeepingAdding retrospective ALT attributes to IMGOn a short walk from homeWeb site traffic - real users, or just noise?Perl and the Common Gateway Interface - out of fashion but still very useful?Do not copy and paste code - there are much better waysChristmas Day ...Ten years ago, we moved to Melksham SpaThe great thing about snow ....How well do you know Melksham - a quiz for Christmas
4659 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94 at 50 posts per page
This is a page archived from The Horse's Mouth at
the diary and writings of Graham Ellis.
Every attempt was made to provide current information at the time the
page was written, but things do move forward in our business - new software
releases, price changes, new techniques. Please check back via
our main site for current courses,
prices, versions, etc - any mention of a price in "The Horse's Mouth"
cannot be taken as an offer to supply at that price.
Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).