Category Archives: Programming

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.

sub do_something () {
  my $parameter = shift;
  ...
}

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.

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.