Now that we’ve launched our new website we decided to write a few words about the technology behind it.

To squeeze some technical terms in as an executive summary, we have moved from PHP to a Perl/mod_perl/Catalyst solution.

Catalyst is a Web Framework, written in the Perl Programming language. mod_perl allows Perl code to run embedded in the Apache webserver, providing a great deal of speed, and access to the internal Apache API. As we have a variety of services running, we decided that it was appropriate to run the main website through catalyst, and switch some of our services to operate in the mod_perl environment.

Like many Web application frameworks, Catalyst encourages a separation of concerns along the approximate Model View Controller Pattern. mod_perl provides raw speed but offers very little in the way of application support. Catalyst is extensible, via modules released on CPAN – a rather dated looking, but comprehensive, collection of Perl Modules available to download.

We started the project some time ago, with a review of the issues we were having with the old site, and the effect on development processes. Programmers reading this will be familiar with the law of diminishing returns that can apply to rapidly assembled sites where speed of delivery rather than potential for maintenance is the overriding concern.

At Majestic, we have experience of a large number of programming languages, and we felt that despite having solid skills in C# and java, our web development needs were best met by choosing a more dynamic language ( such as Perl, PHP, Ruby or Python ). After reviewing our skills base, Perl or PHP became our preferred language choice.

We came to the impression that Catalyst is becoming the preferred way to write Web Applications in Perl – a language famous ( or should that be notorious? ) for there being “More than One Way To Do It”, and whilst Perl is a little out of vogue, in some ways the lack of being fashionable was a bonus for us – it meant we could focus on the technology without being blinded by overenthusiastic advocacy or promises of future features.

There was some concern expressed internally about migrating to a new language, but migration has provided benefits – by removing PHP entirely we didn’t have to deal with any temptation to just copy “trickier” code across to the new system – a key motivator for starting the project, but one that can be easily lost in the rush to launch. The enforced discipline was frustrating at times, but in hindsight beneficial to the integrity of the new site.

A key factor in our decision to switch to Catalyst was the ease in which it integrated with Template::Toolkit – a robust and powerful templating system which provides a nice syntax for designers to code HTML, and enforces separation between the controller and the view implementation.

A snippet of code which was used in a Template from one of our Advanced Reports follows:


      [% FOREACH row IN BackLinks %]

            [% SET alternator = ( loop.count % 2 ) %]

            [% SWITCH alternator %]
                  [% CASE 0 %]
                       <tr class="even">
                  [% CASE 1 %]
                       <tr class="odd">
                  [% CASE DEFAULT %]
            [% END %]

           <td align="center">
                  [% loop.count + ( form.s or 0 ) %]

           <td align="left"><a href="[% row.SourceURL | url %]">
                  [% row.SourceURL | truncate(43) | html %]</a>

           <td align="right"> [% row.ACRank %]</td>

As with many templating systems, Template::Toolkit has a simple syntax for controlling page structure. In addition to Loops and conditional blocks, filters ( show above on the SourceURL line ) can be chained easily, and its a simple process to write new plugins and filters if there isn’t a built in one to do what you want.

Catalyst provides a good degree of application support, and the gentle enforcement of MVC (the easiest way to use catalyst, not the only way to use catalyst ) gave me a feeling of confidence that it was a well designed, considered piece of software.

Here is a fragment of code ( slightly tweaked ) from our Neighbourhood checker:

      sub neighbourhood_checker : Path('/neighbourhood-checker')

            my ( $self, $c ) = @_;

            my $domain = $c -> req -> params -> {"d"};      

            if ( $domain )

                  my $message = $c -> model(RPC') ->
                        RPCFunctionCall(Domain => $domain);

In Catalyst, Perl Object methods are tied to URLS using attributes ( such as the path after the method declaration above ). Catalyst encourages you to keep the catalyst specific parts of the model light – encouraging you to write an Adapter which references a re-usable underlying model. In our case, the website talks to our Application servers using a similar protocol to that offered by our API, which lends its self perfectly to this approach.

Catalyst is flexible with its views, and I’ve been particularly impressed by the ease in which its possible to write AJAX queries and the corresponding server side code using Catalyst View JSON and the popular javascript library jquery. There are also views available for binary data such as charts, graphs and other images, and it isn’t hard to write your own if there isn’t one that fits.

Another nice feature of catalyst is the support scripts – it’s possible to get a server up and running with a couple of lines of code on the command line. Its so easy to get up and running that catalyst has found its way into a few internal projects already.

There is an active online community surrounding the Perl programming language, which is distributed through real and web space – from online sites such as, The Perl Documentation Site and The perl blogs server. to local user groups ( strangely called “Perl Mongers” ) such as London Perl Mongers and Birmingham Perl Mongers . The Perl Mongers groups often hold local, national, and international seminars and conferences which can offer an inexpensive way of learning about the Perl programming language, and associated technologies such as Catalyst.

I’ll close off with a personal recommendation for some further reading, as there are a couple of books published for catalyst – my favourite being “The Definitive Guide To Catalyst“, a copy of which sits on each of our web developers desks. The link takes you to one of the authors blog entries, which covers the book and the recent changes to “Perl Culture” in a little more detail.

Steve Pitchford

Steve has a been in tech since the late 90's, learning the ropes with a UK e-retailer through much of the first dotcom boom after developing a passion for the web during his BSc in Computer Science.

Steve has been engaged with the Birmingham tech scene for years, co-organising the grassroots open-source conference YAPC:: Europe 2008, and founding the West Midlands Java User Group in 2014.

Steve Pitchford


Comments are closed.

If you have any questions in the meantime, please contact
You have successfully registered for a Majestic Demo. A Customer Advisor will contact you shortly to schedule a suitable time to connect.