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 ]

TeeJay (2309)

  (email not shown publicly)

Working in Truro
Graduate with BSc (Hons) in Computer Systems and Networks
pm :,,
lug : Devon & Cornwall LUG
irc : TeeJay
skype : hashbangperl
livejournal : hashbangperl []
flickr :hashbangperl []

Journal of TeeJay (2309)

Wednesday January 13, 2010
07:20 AM

note to self

note to self.. if puzzled why changes to a function/sub/method seem to have no effect make sure you don't have *any* warnings disabled, but especially the redefined sub one.. otherwise you'll never spot the accidentally pasted duplicate of the sub you want to change

Wednesday November 11, 2009
05:16 AM

Maypole now Maint only

I've come to the conclusion that as I have neither the time nor inclination to spend my spare time working on Maypole, and I haven't used it for any paid work for several years, I won't be investing any more time on actively working on it.

However, I could be persuaded to work on it for a decent fee, and I would be happy to apply any patches applied and release new versions with fixes.

I'd also be happy to hand over the reins to anybody who wants to take over.

I do have a lot of ideas in this area, but family and work commitments mean that I'll more likely experiment on top of the newer frameworks that exist than try and rework Maypole beyond recognition.

I still think there is a large hole in the "market" for a more high-level app server than Catalyst, etc providing something more like Drupal in perl but I'm not entirely sure how to do it.

I guess I'll just see what happens, in the meantime I have plenty of other open source code I'm interested in and hacking on - from Autodia to Padre and Plack.

Monday August 24, 2009
08:01 AM

Small F/LOSS projects still gather a lot of contributors

I first released Autodia back in late 2000, it's a fairly small project, doing a specific and small job of interest to some programmers.

I remember how pleased I was the first time somebody emailed me about it, saying thanks and how useful it was. It was a huge surprise and I was really chuffed, that somebody the other side of the world (I think it was South America), had found it and thought to contact me.

Nearly 10 years later it's almost an every day thing. The number of contributors is now just under 50, with another 20 or so bug reporters.

All that for a pretty simple tool that has no mailing list, a couple of (unfortunately out of date) web pages, and only had public version control since last year.

I put almost no effort at all into publicising it, releases are infrequent and the website needs work - but still people find it, post patches and test cases and even sometimes just say thank you without requesting a bug fix.

04:04 AM

Adding a new submenu and core feature to padre in an evening

Last night I decided I'd spend a few hours adding something like gedits 'insert date' and any office program's Insert stuff menu.

Previously I'd spent about 25 minutes looking at how the snippets feature worked and how it fitted into menu's dialogs, etc - just enough time to copy it and modify the menus

Adding a new submenu is fairly simple

+       my $submenu = Wx::Menu->new;
+       $self->{insert_submenu}  = $self->AppendSubMenu( $submenu, Wx::gettext('Insert') );
+       $self->{insert_special} = $self->add_menu_item(
+           $submenu,
+           name       => 'edit.insert.insert_special',
+           label      => Wx::gettext('Insert Special Value'),
+           shortcut   => 'Ctrl-Shift-I',
+           menu_event => sub {
+               require Padre::Wx::Dialog::SpecialValues;
+               Padre::Wx::Dialog::SpecialValues->insert_special(@_);
+              },
+           );
        $self->{snippets} = $self->add_menu_item(
-               $self,
-               name       => 'edit.snippets',
+               $submenu,
+               name       => 'edit.insert.snippets',
                label      => Wx::gettext('Snippets'),
                shortcut   => 'Ctrl-Shift-A',
                menu_event => sub {

The new insert sub menu now holds 2 entries - snippets, and 'insert special value', which calls insert_special method on the new Dialog class, which will be defined next

That's easy enough - now to add some actual functionality..

We define the functionality in the dialog class just below :

  • The menu item calls insert_special, which simply calls the dialog method.
  • The dialog methid is where most of the setup is done, layout of the dialog and the widgets, specifying what functions to call when widgets are clicked or selected
  • The widgets are best understood by looking at the examples in wxdemo, and Padre::Wx::Dialog which wraps some of the logic.
  • The Choice widgets just expect an array ref of labels, when a selection is made the indice of the selection is available from the widget object - see get_value and get_category for examples of mapping selection indices into your own data structures.
  • You can access the current editor object and thence document, etc using Padre::Current, see the _get_file_info sub.

And now for the source code in full..

package Padre::Wx::Dialog::SpecialValues;

# Insert special values such as dates in your code

use strict;
use warnings;
use Padre::Wx         ();
use Padre::Wx::Dialog ();
use Padre::Current    ();

our $VERSION = '0.01';

my $categories = {
          'Dates' => [
                  { label => 'Now', action => _get_date_info('now')  },
                  { label => 'Yesterday', action => _get_date_info('epoch') },
                  { label => 'Tomorrow', action => _get_date_info('epoch') },
          'File' => [
                 { label => 'Size', action => _get_file_info('size') },
                 { label => 'Name', action => _get_file_info('name') },
          'Line' => [
                 { label => 'Number', action => _get_line_info('number') },

my $cats_list = [ sort keys %$categories ];

sub get_layout {
    my ($config) = @_;

    my $default_cat_values = [map ($_->{label}, @{$categories->{$cats_list->[0]}})];

    my @layout = (
        [ [ 'Wx::StaticText', undef, Wx::gettext('Class:') ],   [ 'Wx::Choice', '_find_cat_',  $cats_list ], ],
        [ [ 'Wx::StaticText', undef, Wx::gettext('SpecialValue:') ], [ 'Wx::Choice', '_find_specialvalue_', $default_cat_values ], ],
        [ [], [ 'Wx::Button', '_insert_', Wx::gettext('&Insert') ], [ 'Wx::Button', '_cancel_', Wx::wxID_CANCEL ], ],
    return \@layout;

sub dialog {
    my $class  = shift;
    my $parent = shift;
    my $args   = shift;
    my $config = Padre->ide->config;
    my $layout = get_layout($config);
    my $dialog = Padre::Wx::Dialog->new(
        parent => $parent,
        title  => Wx::gettext("Insert Special Values"),
        layout => $layout,
        width  => [ 150, 200 ],

    Wx::Event::EVT_CHOICE( $dialog, $dialog->{_widgets_}->{_find_cat_}, \&find_category );
    Wx::Event::EVT_BUTTON( $dialog, $dialog->{_widgets_}->{_insert_}, \&get_value );
    Wx::Event::EVT_BUTTON( $dialog, $dialog->{_widgets_}->{_cancel_}, \&cancel_clicked );


    return $dialog;

sub insert_special {
    my $class  = shift;
    my $main   = shift;
    my $dialog = $class->dialog( $main, {} );

sub find_category {
    my $dialog   = shift;
    my $cat_name = _get_cat_name($dialog);
    my $values   = [map ($_->{label}, @{$categories->{$cat_name}})];
    my $field    = $dialog->{_widgets_}->{_find_specialvalue_};

sub get_value {
    my $dialog = shift;
    my $data   = $dialog->get_data or return;
    my $cat_name    = _get_cat_name($dialog);
    my $value_ind = $data->{_find_specialvalue_};
    my $text   = &{$categories->{$cat_name}[$value_ind]{action}};
    warn "cat : $cat_name, value $value_ind, text : $text\n";

    my $editor = Padre::Current->editor;
    my $pos = $editor->GetCurrentPos;
    $editor->InsertText( $pos, $text );

sub cancel_clicked {


sub _get_cat_name {
    my $dialog = shift;
    my $data   = $dialog->get_data;
#    warn Dumper (data => $data);
    my $cat_name  = $cats_list->[$data->{_find_cat_}];
    return $cat_name;

sub _get_date_info {
    my $type = shift;
    if ($type eq 'now') {
    return sub {
        return scalar localtime;
    } else {
    return sub {
        warn "date info $type not implemented yet\n";
        return '';

sub _get_file_info {
    my $type = shift;
    if ($type eq 'name') {
    return sub {
        my $document = Padre::Current->document;
        my $filename = $document->filename || $document->tempfile;
        warn "doc : $document $filename \n";
        return $filename
    } else {
    return sub {
        my $document = Padre::Current->document;
        my $filename = $document->filename || $document->tempfile;
        warn "doc : $document $filename \n";
        return ($filename) ? -s $filename : 0;

sub _get_line_info {
    my $type = shift;
    return sub {
    my $editor = Padre::Current->editor;
    my $pos = $editor->GetCurrentPos;
    my $line = $editor->GetCurrentLine;
    return $line + 1;
    } ;

It's mostly an exersize for me in hacking padre and a proof of concept for a word-processor style insert menu, at the moment, but I hope to integrate plugins so that, for instance, a version control plugin would allow you to paste the name of the repo, or the version, tag or branch into the document.

Tuesday February 03, 2009
02:46 PM

New testing module : Test::HTML::Form

I've released, with the kind permission of Slando, Test::HTML::Form which makes testing HTML and HTML::Forms considerably easier.

The API is loosely based on Test::HTML::Content, but it use HTML::Treebuilder and re-uses parse trees and objects where possible, making it much quicker - it also uses filenames instead of passing strings around, and has additional methods for extracting strings and testing form elements easily

So far it's already made a lot of testing easier, but I already have a wishlist of extra features - like being able to extract HTML::Elements easily, provide urls instead of filenames, and allow extra tests on more form elements.

Anyway.. its in SVN at and on CPAN

Monday December 29, 2008
08:29 AM

Python and Perl on sourceforge

I tried posting another response to david at but his blog doesn't cope with long replies. I posted it here..


I can't even post a response on your blog so I posted it here :

What those of us who actually have written and developed open source perl projects are saying is that sourceforge is a very poor indicator of anything but sourceforge usage in languages.

I think you're article would be much better if you turned it on it's head : Which languages use sourceforge, vs which languages have strong software repositories of their own.

Ruby has it's gems, php has pear, Python has the caverns of thingywotsit.

CPAN just happens to be far larger and better equipped than the alternatives.

As a free software author it's simply not worth the effort of using sourceforge for any of my projects - CPAN provides better tools and distribution, I have my own homepages for my projects.

I would probably even surmise that Sourceforge is actually the thing that is losing market share : you have better and more focussed alternatives like ohloh, github and google code, most significant projects will host their own version control, bug tracking and wikis.

"f CPAN shows some growth for Perl, that seems normal to me - if there's no growth there, the language really would be dead."

16% is more than just healthy growth - it indicates exactly the opposite of your conclusions!

"Freshmeat indicates that, relative to Python and other languages, Perl isn't seeing as much code released."

I'd turn that on it's head : the usage of freshmeat indicates the lack of better alternatives for other languages.

CPAN and PEAR have both moved forwards a great deal since sourceforge was created, yet sourceforge is pretty much identical to how it was in the 90s.

"The point that perhaps people are less interested in Freshmeat these days isn't a bad one (although "myself as a case study" isn't great statistics either), but why should that be different for Python, Perl or, say, Lua users? If it's going to drop off, it'll drop off for everyone."

Because other languages don't have a decent repository of their own and/or have different eco-systems.

Despite the existance of PEAR, PHP is still dominant on freshmeat, but PEAR and Freshmeat don't overlap much - one being for applications one being for libraries.

"Python, however, is growing, whereas Perl hasn't. I'm sorry if that upsets you, but those are the relevant facts."

No - all you've shown is that freshmeat is more popular with python coders than perl ones.

"However, it is not as popular as it once was, in terms of new code being written."

Again, you can't sensibly draw this conclusion when you know that CPAN growth is 16% year on year.

You probably don't even have figures to compare growth in the vaults..

A quick check of the web page shows "Parnasus Totals: 2025 items in 49 categories." CPAN yearly growth is larger than the entire Panasus repo!

Maybe Python has a new repo - Parnasus looks like it hasn't been updated or worked on since the 90s - that would certainly explain why pythonista's tend to rely on sourceforge.

Yup, there is a new repo : 5393 packages on

So python has 5393 packages on cheeseshop, 3200 on sourceforge, and 2000 on parnasus.

CPAN has 14793 packages on CPAN and 3800 on freshmeat.

CPAN growth is 16%, Perl growth on sourceforge is 1.1%, Python growth is 1.4%.

Looks to me like python is being held back by the lack of a CPAN.

Monday December 15, 2008
11:00 AM

optimising for fun

I came accross two blog posts today on enjoying your open source / personal projects and it's a helpful reminder that I don't need to stress about the projects I have.


both very good, with reminders of the fact that if you're not getting paid or some other reward and it's not fun, then it's probably not worth doing.

It's also worth remembering the flip side of the coin - nobody owes you support or bug fixes in a project they're doing for free on their own time.

And finally, I got what you always ask for as a writer or maintainer of open source (or heck even commerical) code :

an unsolicited patch with test and explaination.. somebody read the README, and did exactly as I wishfull thinkingly asked and then seemed surprised that I was surprised.

in the words of Patrick Nice[1].. "which was nice"


Thursday December 04, 2008
03:26 PM

Influx of redditors

What's the betting all the people who turned up just to say that perl is dying won't be back to post anything at all tomorrow or the day after or ever again.

What's the odds that most of them never even bothered to join a perl monger group or attend a talk on perl "back when they used perl" before they discovered that python was all rainbows and unicorn. ?

Fairly low.

How insecure do you have to be to join just say how much you prefer python ?

lame, lame, lame.

Monday November 17, 2008
05:12 PM

Hacking emacs keybindings into Padre

I've been meaning to play with Padre (An Editor/IDE written in Perl) as it has perl extensions and therefore I can do with it, what lisp gurus can do with emacs, without the use of mind-altering drugs or lambda calculus.

This evening, in the space of 90 minutes I was able to add some very basic emacs keybindings, only a handful, and some of them work, while some still have their original bindings, despite using "$self->CmdKeyClear(ord('w'),Wx::wxMOD_ALT());" which should unbind them. Bah.

Anyway, that's enough for now, but it has encouraged me to hack on it some more when I get the chance and to start integrating autodia based tools for generating and creating documentation and code at the click of a mouse.

You can find the results of my efforts at :

Thursday November 13, 2008
07:44 PM

Maypole development sprint - adding DBIx::Class Model

For the last few weeks, while my better half has been away on training for her new job, I've been doing a bit of housekeeping on Maypole.

This week I've been adding a DBIx::Class model, progress was pretty slow and painful initially, but now it's going much better and I end up "in the zone" only to realise that it's almost 1am and I will probably have to get up at 6am (again, done this 3 nights in a row, once reading a book, twice hacking code)

Headache, Gritty, burning eyes, but it's worth it - I just managed to get the list action working (apart from autocreating embedded forms and buttons) with the new DBIx::Class model.. soon I'll be able to use Maypole with DBIx::Class for both work and personal projects.