Category Archives: Programming

Building Web Sites with Perl

Over on my other blog last night I wrote a piece about how building simple web sites has never been easier. I talked about how it’s really simple to use something like WordPress or Drupal to build a web site that will suit the needs of many organisations – charities, schools, organisations like that.

You’ll have noticed that both Drupal and WordPress are written in PHP. If I was going to include another item on the list, it would probably be Joomla – which is also written in PHP. The first Perl-based system on my list would be Movable Type (or perhaps Melody, the community-driven fork of MT).

I use MT to build blogs (this site is built with MT). I also used it to build my company web site. So why isn’t in my top three suggestions? Well for two reasons. Firstly I don’t think that it’s quite as easy to use for non-technical people as the other systems on my list. And secondly, last year I tried to use MT to build something more complex than a single-blog site and it all went horribly wrong. With some help from the people at Six Apart those problems are getting sorted out and hopefully the project will be launched soon, but I’m currently wary of recommending MT to end users wanting to build sites.

Of course MT gets better all the time. The MT5 betas look really nice and I’m really hopeful that Melody will be a great end-user CMS. But currently I’d still recommend Drupal and/or WordPress.

End users don’t care at all what technologies their web sites are built in. As long as the site looks good and works well, why should it matter to them whether the site is written in PHP, Perl or anything else? But from the point of view of language advocacy, I’d like to be able to recommend something that’s written in Perl.

So what can we do? Well, firstly, you can tell me if I’m missing anything. Is there some other Perl-based simple web site builder that has completely passed me by? What systems would you recommend (or use yourselves) if, for example, a local school asked for help building a simple site?

And if there isn’t something that I’ve missed? Should a group of us sign up for the Melody project in order to ensure that it becomes a worthy alternative to Drupal? Is there some other project that we can co-opt to this purpose?

Or do we just not care? Is it ok that we’re in danger of losing the low-end web CMS market to PHP systems?

Perl Twitter Feed

Last August, when I was writing my talk Proud to Use Perl for YAPC::Europe, I wanted to get a feel for what real people were actually saying about Perl. It’s all very well claiming that people say Perl is dead, but I wanted to get some real quotations to use in the talk. I came up with the idea of using Twitter. I set up a Twitter search feed for tweets containing the word “perl” and monitored that for a couple of days. I quickly got all of the quotations that I needed.

But I found the feed fascinating, so I continued to read it. Sometimes the Perl community can be a little insular, so it was interesting to read what other people were saying about Perl. I still read the feed today.

Over the year, the feed definitely feels like it’s getting bigger. I mean, there are more mentions of Perl. I don’t have any concreate figures because I read the feed at random times of the day and sometimes don’t touch it for a couple of days. It’s tempting to think that more talk about Perl is due to things like the Ironman initiative, but we shouldn’t jump to that conclusion. Firstly, more talk about Perl could just mean more people saying that Perl is dead (I don’t think this is the case) but secondly more talk about Perl could just be indicative of more talk on Twitter in general. Certainly the number of users on Twitter is still grwoing quickly, so that could probably explain the growth in Perl talk.

But over the last week or so, I’ve gradually realised that a lot of the increase in tweets mentioning Perl is due to the increase in spam (or, at least, spam-like) tweets mentioning Perl. I see a huge number of posts from accounts like @e_host which do nothing but advertise web hosting companies. I suppose we should take it as a positive sign that they think Perl is a feature worth mentioning in these adverts. There’s also been an increase it tweets that are reposts from hire-a-freelancer sites. For example, this morning I saw dozens of copies of this “Need Perl Expert” post.

I’m seriously considering dropping the Perl Twitter feed from Google Reader. It’s just becoming such a slog to go through it. I estimate that about a third of it it currently interesting – and that signal to noise ratio is only going to fall.

I do think, however, that it would be useful and interesting (and pretty easy) to set up an application which monitors the feed and records the data. If we just counted the number of posts, that would be interesting. We could even consider pushing the text through some kind of analysis to pull broad types of information from it (“is this a positive or negative mention of Perl?”). The sooner we start, the more data we’ll have to play with.

I think I’ll set something up tomorrow.

What is Wrong With this Picture?

I’ve just found a number of subroutines defined this way in the code that I’m working on.

I discovered the problem because I started getting errors about “too many parameters”. I knew what the problem was (the empty prototype) but it took a couple of minutes of head-scratching before I realised why it had been working before my changes.

Then I realised.

I have a dislike of “unnecessary” &s on subroutine calls. So almost without realising, I had removed them from the calls to these functions.

A few lessons have been learned.

Lesson 1 (for the original author of this code): Prototypes will trip you up. Do not use them.

Lesson 2 (for me): Ampersands aren’t always as pointless as they appear. They may be masking bugs in the code.

CPAN Web Feeds

I’m still thinking about adding stuff to this blog. I’d like to add some web feeds to the sidebar. In particular, I’d like a feed of my CPAN uploads. I don’t expect it to be a particularly busy feed (although having such blatant evidence of my laziness might galvanise me into being a bit more productive) but was surprised to see that such a feed doesn’t seem to exist.

CPAN has a “latest uploads” feed, And there are a couple more documented in the FAQ, but none of those do what I want.

It seems a simple enough idea. I can pull down the latest uploads feeds and filter it on my name. But before I do that I thought it was worth invoking the power of the lazyweb and asking if anyone else has already scratched that itch.

Testing Syntax Highlighting

Right. I think I might have got this cracked now. Here’s some Perl code.

That’s pretty cool, isn’t it. I wonder what it’ll look like in the web feed.

I’ll try to feed my fixes back to the author of the plugin.

Syntax Highlighting

One of the nice things about moving away from use.perl to your own site is that you can install whatever toys you want.

I’ll eventually get round to posting code on this blog. And when I do it would be nice if it had some nice syntax highlighting. I could, of course, write my own syntax higlighter (probably based on something like PPI:HTML) but that sounds far too much like hard work, so a couple of days ago I decided to poke around to see what prior art was out there.

Initially, it looked like I was in luck. In the Movable Type plugins directory I found a link to SyntaxHighlighter for Movable Type, which is an MT wrapper around SyntaxHighlighter 2.0. The example output looked rather nice.

I downloaded it and installed it. And then I prodded at it for an hour or so. But all to no avail. It didn’t seem to work as advertised (or, indeed, at all). I fixed one obvious bug in the Perl support but it didn’t seem to help. I hope that the problem is just that Perl support hasn’t had as much testing as other languages[1]. There’s no obvious route for support, so I’ve left a message for the author on his blog. Hopefully he’ll get back to me and we can get this ironed out.

But, all in all, it looks like I’m not going to be able to be as lazy I’d like to be.

Unless, dear readers, you know better. Do you know of a syntax highlighting plugin for Movable Type? Have you patched this one to work? Is there an alternative solution that I’m missing completely?

[1] Which is only to be expected as Perl is, as I’m sure you realise, a dead language :-)

Update: Thought I’d take a look at the Javascript to see if I stood any chance of debugging it. Look at this!

Updated update: People more on the ball than me have pointed out that a) the horrible-looking Javascript has been minified and b) the original code is on bitbucket.