Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

AndyArmstrong (7200)

  (email not shown publicly)
Sunday December 16, 2007
02:11 PM


Yesterday I posted a GreaseMonkey script to add a CPAN Dependencies link to

The only problem with that is that FireFox is not my main browser. I tend to use FireFox for web development (FireBug++) and Safari for general surfing. Theoretically you can use GreaseMonkey scripts in Safari using CreamMonkey - but I couldn't get that to play nicely with Leopard.

So I've released HTTP::Proxy::GreaseMonkey which builds on BooK's excellent HTTP::Proxy to provide a local proxy that functions like GreaseMonkey.

Version 0.01 of HTTP::Proxy::GreaseMonkey has no support for the GM_* utility functions that the real GreaseMonkey provides - but it works well enough to support my CPAN dependencies user script and probably quite a few other GM scripts. Suggestions are welcome. Suggestions with patches even more so.

Saturday December 15, 2007
01:52 PM

CPANdeps + Greasemonkey

I've just written a quick and dirty Greasemonkey script that adds a link to David Cantrell's excellent CPAN dependencies to any CPAN distribution's page on

// ==UserScript==
// @name           CPAN Search
// @namespace
// @description    Add links to CPAN
// @include
// ==/UserScript==

var new_links = {
    'CPAN Dependencies': function(url, name) {
        return ''
            + escape(make_module_name(name));

function canonical_url() {
    var permalink = document.getElementById('permalink');
    if (permalink) {
        return permalink.firstChild.href;
    return '';

function trim_url(url) {
    return url.replace(/^http:\/\/[^\/]+\/[^\/]+\//, '').replace(/\/$/, '');

function make_module_name(dist_name) {
    return dist_name.replace(/-/, '::');

function add_links(nd) {
    var end = nd.lastChild;
    var dist_url  = canonical_url();
    var dist_name = trim_url(dist_url);
    // console.log(dist_name + ' ' + dist_url);
    var keys = [];
    for (var k in new_links) {
    keys = keys.sort();
    for (var l = 0; l < keys.length; l++) {
        nd.appendChild(document.createTextNode(" ]\n[ "));
        var name = keys[l];
        var link = document.createElement('A');
        link.href = new_links[name](dist_url, dist_name);
        link.innerHTML = name;
        // console.log(name + " " + link);


var rows = document.getElementsByTagName('tr');
if (rows) {
    for (var r = 0; r < rows.length; r++) {
        var cells = rows[r].getElementsByTagName('td');
        if (cells.length == 2 && cells[0].innerHTML == 'Links') {

I'm sure the DOM walking can be improved - but it works. To add other links add them to the new_links hash. Each entry is the anchor text for the link and a function that returns the URL to link to.

Tuesday November 06, 2007
08:49 AM

Test::Harness 3.00

We've just released Test::Harness 3.00. It's a complete rewrite of Test::Harness with a more modular architecture that should make it easier to write custom testing tools.

In no particular order here are some of the things that have changed:

  • Support for TAP version 13
  • Cleaner API
  • Closer integration with CPAN::Reporter
  • Parallel test runs
  • Improved output formatting
  • Machine readable YAML diagnostics
  • Better detection of TAP syntax errors

And in alphabetical order some of the people who made it happen:

  • Sebastien Aperghis-Tramoni
  • Leif Eriksen
  • Shlomi Fish
  • David Golden
  • Jim Keenan
  • Andy Lester
  • Michael Peters
  • Curtis Ovid Poe
  • Michael Schwern
  • Gabor Szabo
  • Eric Wilhelm


Development on Test::Harness continues. There are a number of proposals on the Test Anything Wiki and at least some of them will make it into future releases. If you'd like to follow progress more closely - or offer some help - you'll find the Test::Harness developers on the TAPX-DEV mailing list or on #toolchain on IRC.

Thursday November 01, 2007
05:06 PM

Leopard's tar is broken

I've just upgraded my MBP to Leopard. Apple's version of tar has the annoying habit of generating extra files to represent Mac specific attributes. That's particularly annoying for CPAN authors because they tend to break your test suite and you can't easily see them without unpacking the archive on a non-Mac system. Grrr.

It used to be possible to disable this behaviour by setting the env var COPY_EXTENDED_ATTRIBUTES_DISABLE to some true value - but this seems to have stopped working in Leopard. As a result I've just released a broken version of Captcha::reCAPTCHA. Double Grrr.

strings /usr/bin/tar fails to reveal anything promising, /usr/bin/gnutar is just a hard link to /usr/bin/tar and I can't get the MacPorts gnutar to build so for now I've restored a copy of Tiger's tar from a backup and dumped it in ~/bin (which I have on my path). Phew.

Watch out Mac-based module authors - it's hard to detect that you have a broken archive without testing it on a non-Mac machine.

03:30 PM

Testing on VMS

As previously reported progress on Test::Harness 3.00 ran aground temporarily while we worked out how to run our test suite on VMS. We're back on track now, running our smoke tests automatically on a VMS TestDrive account.

With help from Craig Berry and Michael Lemke I've put together a page on the Perl-QA Wiki that describes the process:

It includes a link to the script we use to remotely execute our test suite. If I've missed anything important or made any errors please feel free to dive in and fix them.

Monday October 22, 2007
07:58 AM

Perl Flavoured Google

For the last few months I've been using a couple of Perl specific Google Co-op searches.

The Perl search pulls results from 72 assorted Perl related sites including CPAN and It tends to work for those questions that you're not even sure where to ask.

Perhaps more useful is the CPAN search which I find often outperforms In particular it finds 'one word' module names like CGI or FCGI both of which currently overlooks.

If you have any suggestions for sites I've missed or other improvements give me a shout.

Tuesday October 16, 2007
12:06 PM

The Future of Test::Harness::Straps

One of the implications of the work on Test::Harness 3.0 is that Test::Harness::Straps will no longer exist as part of Test::Harness.

For new applications you are encouraged to use TAP::Harness / TAP::Parser. The awkwardness of Straps was one of the reasons to embark on a rewrite of Test::Harness and the new code should make it far easier to write ad-hoc testing applications.

That leaves the question of what should happen to Straps. As Schwern points out it will still work once you have installed Test::Harness 3.0 - but it would be orphaned: installed but unmaintained with no updates available.

The solution might be to make an independent release of Test::Harness::Straps. There's a slight danger then that people would continue to use it for new code but the documentation would carry warnings about the inadvisability of that - and ultimately if someone finds it useful, why not?

Let me know what you think.

Sunday October 14, 2007
11:08 AM

The Faces of CPAN

Now that some of us have added our Gravatars to CPAN I thought it'd be fun (and perhaps a little scary) to collect all the available mugshots in one place.

The Faces of CPAN

We're disappointingly white and male - but who knew how damn fine we'd look as a group? Somebody should organise a naked calendar photo shoot next. People would pay lots of money not to see that.

Saturday October 13, 2007
10:12 AM

Strawberry Perl

David Golden recently alerted me to his Strawberry Perl distribution for Win32. It bundles GCC, dmake and a slew of useful modules and for my money provides a better out of the box experience than ActiveState. The default for installing modules is cpan rather than ppd and the bundled GCC means that XS modules build just fine. It also bundles David's excellent CPAN::Reporter which means you'll be giving module authors helpful Win32 feedback every time you install.

It's currently alpha but I found it completely stable. It manages to work pretty much like Perl on other platforms without having to pretend that Windows is another platform (à la Cygwin).

Highly recommended, thanks David.

Friday June 01, 2007
11:34 AM

CPAN v DTD (spoiler: CPAN loses)

I need to parse a DTD. Specifically I need to parse this DTD:

It's quite a well known one. Certainly there'll be a module on CPAN that can parse it. Let's have a look.


Looks promising, comprehensive. Unfortunately it fails with an error which is eventually tracked to a misspelled method name. So much for test coverage. Fix that and it throws a bunch of warnings that cause a rapid loss of confidence. No matter, let's try...


It's a "quick and dirty DTD parser". Hmm. "I'm too lazy to document the structure". Nice.

"Since version 1.6 this module supports my "extensions" to DTDs. If the DTD contains a comment in form"

Maybe I'll come back to XML::DTDParser...


SGML? That's got to be good, right? SGML is the daddy. Every fule no that. Unfortunately it doesn't really seem to have much of a Perl interface. It's all about translating DTDs to XML. I might be able to use that. I'm getting desperate.

I'll take a quick look at the test suite for a confidence boost. Here's one:

    # Before `make install' is performed this script should be runnable with
    # `make test'. After `make install' it should work as `perl SGML-DTDParse.t'


    # change 'tests => 1' to 'tests => last_test_to_print';

    use Test::More tests => 1;
    BEGIN { use_ok('SGML::DTDParse') };


    # Insert your test code below, the Test::More module is use()ed here so read
    # its man page ( perldoc Test::More ) for help writing this test script.

The other test is pretty similar. I'm not that confident now.


Running out of options. Let's look at XML::ParseDTD. From the documentation it appears to rock. The test results say "2 PASS, 2 FAIL". 50/50. So at least it's got some tests, right? Damn right! Here they are in their entirety:

    #!/usr/bin/env perl -w

    use strict;
    use Test::Simple tests => 2;
    use XML::ParseDTD;

    my $dtd = new XML::ParseDTD('');         # create an object
    ok( defined $dtd, 'new() returned something' );                # check that we got something
    ok( $dtd->isa('XML::ParseDTD'), 'it\'s the right class' );     # and it's the right class

I'm momentarily impressed that it managed to score two failures with that. I'm about to find out how.

Never mind, the DTD URI in the test looks a lot like the DTD I need to parse. I'm getting close. I can feel it.

Unfortunately it has a dependency on Cache::SharedMemoryCache (why?) which in turn depends on IPC::ShareLite - which doesn't install on my PowerBook. So now I need to fix / avoid IPC::ShareLite.

See kids: the great thing about CPAN is how much time it saves!