Web programming in Perl
May
14
I started programming Perl in 1999. Back then, I threw together Web pages using CGI scripts. Some of my earliest scripts combined code and markup, and quickly became unmaintainable. Since then, I’ve programmed in other languages, including Java, C#, Python and PHP, but I keep coming back to Perl. The language has evolved and matured, while new frameworks and libraries have made Web programming fun again.
Most recently for UF, I’ve built a Web site deployment tool using Perl called SiteDeploy. We’re using it internally at WebAdmin on top of
our Subversion repository to manage the UF Home Page and most of our other sites. It gives everyone here an overview of what has changed and when things were pushed live.
SiteDeploy uses the Catalyst Web framework to take advantage of Perl’s flexibility and huge library of existing code. Catalyst encourages use of the model-view-controller pattern, similar to Ruby on Rails. In SiteDeploy, the code for interacting with the Subversion repository (the model) is completely separate from the code that displays the user interface (the view). There’s a thin layer (the controller) that talks between the two based on input from the user.
The model layer uses Moose, which simplifies Perl object-oriented programming. The code is easier to maintain and much easier to read. Moose also gives you some basic type checking, but doesn’t force you to cast between types like in some other languages. instead of calling the svn binary or using the Subversion bindings directly in SiteDeploy, I’m using VCI. VCI gives you a unified interface to multiple version control systems, so in theory WebAdmin could move to Git with little effort.
One of my favorite parts of this project is how easy it has been to add unit tests and acceptance tests. Every time I make a change, I run the tests to make sure I haven’t broken anything. I find and solve bugs sooner, giving me more confidence in my work.
In the future I’ll probably add some additional access control to SiteDeploy so that some of the people we work with can deploy their own sites. This may be built on top of Subversion’s access control, or might be implemented separately in a database. In the latter case, I’ll use DBIx::Class.
I consider Catalyst, Moose and DBIx::Class to be best practices for Perl development these days. If you’ve used Perl in the past, but it’s been a while, or been turned off by TIMTOWTDI, I encourage you to give it another try.
May 14th, 2009 at 3:28 pm
Nice article, DWC.
May 14th, 2009 at 10:41 pm
Is SiteDeploy available for download?
May 15th, 2009 at 8:13 am
Jay,
SiteDeploy is not currently available for download, but there’s talk of releasing it in the future.
I’m also overdue to release our Catalyst-based document/workflow tracking tool under the Artistic license. I’ll be posting it to Google Code soon, hopefully.