Because Perl definitely isn't dead.
Random header image... Refresh for more!

Category — internet

Perl to the rescue…

So it appears there are some drawbacks in WordPress Mu. Mainly that there is a complete lack of a decent content aggregation plugin for it. Well that’s no problem, I’ll just write one…. wait just one minute. Perhaps the reason that their isn’t one already is because Mu is basically a giant hack!

There is an ugly bit of PHP that basically sets the current blog and then everything works, however changing the current blog breaks pretty much everything. Also Mu creates a set of tables for every blog, so all the posts are in different tables. Thus making writing a nice clean Mu plugin to aggregate the posts an impossibility.

So Perl it is then. A quick script to union the tables, TT the data and then print the output. Add a bit of caching and hey presto, done in less than an hour.

Still could use a bit of tidying up in the templates but other than that it’s all good. Anyway it’s running the per.ly homepage now. Also if anyone wants a per.ly blog, to post about anything related to Perl leave a comment.

May 24, 2009   Comments Off

Perl Binaries with PAR

This is something that rears it’s ugly head from time to time, the need to create stand alone scripts that I can give to a none programmer to run on a Windows box. The last time I played with this, it was to create a version of the get_iplayer script for my dad to run. This time it was to run some network diagnostics scripts we’d hacked together on a machine we had no access to.

The machine we needed to run it on was a fairly well locked down ‘doze box, so installing Perl was unlikely to happen. The last time I used a nice little app called linux2perl. It worked fairly well, but the free version had a 2 second delay and a splash message on the start of the app.

So I decided to take a look at the Perl Archiving Toolkit (PAR). The PAR toolkit actually generates intermediate shippable packages, that are actually zip files with all the required modules included to run a script. So a PAR script can be packaged up and shipped to any user with perl and it’ll run regardless of architecture (almost… think XS), or installed modules.

To my delight, creating an executable was nice and simple:

pp -o outfile.exe infile.pl

PP is the PAR Packager, which isĀ  nice little utility to convert the PAR files to executables for the current OS. Or as the CPAN page puts it “You may think of pp as perlcc that works without hassle.”

You’ll still need a windows box to build the binaries, but once they’re built they are completely shippable and can be sent to other boxes. Although they do end up being rather large, my simple script was a little under 4 Meg, leading me to wonder if more than just the libraries I used were packaged up too.

Either way it worked perfectly, I even repackaged the get_iplayer script for the old man.

April 8, 2009   Comments Off

P3P Policies are a joke

Initially I thought P3P policies might be quite useful. A nice way to see how a site promises to use my data and I could even configure my browser to treat my privacy settings accordingly.

It was a nice thought at least. Unfortunately the reality is somewhat different. The only browser that seems to even support P3P privacy policies is Internet Explorer. When I say “support”, what I actually mean is, make a complete hash of.

It appears that if you want to use cookies on a third party domain, in an iframe or a image tag for instance, in IE you need to have a P3P policy defined.

Okay, no problem we’ll set ours up. Unfortunately the site I was working on has terms and conditions that state that they can use users data for pretty much anything. Initially IE didn’t appear to have a problem with the policy stating this. The third party cookies worked a treat, but for some insane reason Microsoft in their wisdom decided to turn all first party cookies into session cookies. Which meant the whole system wouldn’t function.

This ain’t news‘ lead developer Mark discovered that Facebook are using a very strange P3P policy, that only contained “CP=HONK”. As we could find no reference to this anywhere we discovered through trial and error that you can put any gibberish in, and IE lets all first party and third party cookies work fine!

So in essence, the only browser that supports P3P policies is IE, and to get round them just put in some Lorem Ipsum. Now that’s a security model.

April 1, 2009   Comments Off