Perl for Umbraco

Disclaimer: I see this as a nice little hack, and something that I’ll use for development and fast prototyping. I’m not recommending it for production use and I know and appreciate that the guys behind Umbraco would probably discourage this in terms of 'best practices'. There is nothing here you couldn't do with C#.

Anyway, having said that, I think Perl is a great and very current technology. I use it day in day out as part of my work with Interwoven TeamSite and it still powers some of the biggest sites on the web including the BBC and parts of Amazon. Web frameworks like Catalyst are excellent and I’m quite prepared to argue my corner with anyone who thinks that Perl is old ‘skool’ and dated.

For those of you who aren’t interested in the technical details here are the links to the samples:

Hello World
Get Login
Format Date
Passing a parameter
Missing script
Dump Request
Script not specified
Current page as JSON
Manipulating text with regular expressions
Replacing words within a string

My favourite sample here is date formatting, Tim recently wrote a post on date formatting using XSLT and I love the simplicity of my sample when it comes to tasks like this.

So, a brief overview of what is going on here.

ActivePerl comes bundled with a product called PerlEx. PerlEx can be configured in IIS as an ISAPI filter which Pre-compiles Perl and significantly reduces the execution time and the overhead of starting a new interpreter with each HTTP request which is what traditionally happened with CGI scripts. The ActivePerl installer takes care of all of this setup for you. Although I’ve said I wouldn’t recommend this for production use, it is very quick. It is quite likely your shared host already has it set up.

I’ve created an HTTP filter using C# that parses Umbraco pages and uses regular expressions to find PERL_MACRO tags – see the examples. The Marco named in the tag is modified to have a .plex extension and a request is made to

Any other Macro params are forwarded as request parameters meaning you can pass values from Umbraco to Perl.

To set up I simply add /plex to my Umbraco reserved paths in web.config and add an HTTP filter.

If you’d like to play with this yourself drop me an email. I'd love your feedback, positive or negative. I'd hoped to show this at codegarden but it wasn't ready.


Leave a comment