pathed - munge the Bash PATH

I wrote "pathed", a tool to munge the Bash "PATH" environment variable.

The Bash "PATH" environment variable contains a colon-separated list of paths. pathed - "path editor" - can split the path, append, prepend or remove elements, remove duplicates and reassemble it.


I've created a new blog at, a site which I intend to use to pimp offer my services, and will use that blog from now on. The design is not quite there yet. :)

5.10 regex features: Build a nested structure while matching

In trying to learn 5.10 grammar-like regex features and wrote a program that, while matching simple Lisp-like constructs, builds up a data structure. This involves recursing into subpatterns, but I couldn't find a way to assemble the resulting tree from the bottom up. Therefore I used a stack.

Do you know of a better way of building the data structure with the given regex/grammar?

(I'm aware of Parse::RecDescent and Regexp::Grammars, but wanted to do this as simply as possible.)

#!/usr/bin/env perl

# Exercising perl 5.10 regular expression features:
# Return a tree structure while matching simple Lisp-like constructs

use warnings;
use strict;
use 5.010;
use Test::More;
use Test::Differences;

sub parse {
    my $string = shift;
    # 'my @S' produces 'Variable "@S" will not stay shared' and failures
    our @S = ();
    # 'my @t' produces 'Can't localize lexical variable @t'
    our @t;

    # Use a stack because I can't see a way of localizing variables when
    # recursing into subpatterns.
    state $re = qr{
               (?{push @S, 'MARK'})
               (?&element) (?: \s+ (?&element) )*
                   local @t;
                   while ((my $el = pop @S) ne 'MARK') { unshift @t, $el }
                   push @S, \@t;
          (?<element>  (?&value) | (?&tree) )
          (?<value> (\w+) (?{ push @S, $^N }) )
    $string =~ $re;
    pop @S;

sub check {
    my ($string, $expect) = @_;
    eq_or_diff parse($string), $expect, $string;
check('(print)', ['print']);
check('(print foo bar baz)', [qw(print foo bar baz)]);
check('(print (foo 1 2) (bar 3 (baz 4 5)))',
    [ 'print', [ 'foo', '1', '2' ], [ 'bar', '3', [ 'baz', '4', '5' ] ] ]);
check('((foo (bar 1)) baz)', [ [ 'foo', [ 'bar', '1' ] ], 'baz' ]);

You can get the code at .

Being anti-social

A few days ago I deactivated my Twitter account and most other social networking accounts. It's not that I'm vanishing off the face of the earth or anything like that - I've just gotten disillusioned with "social" networking. It has grown to be a kind of addiction; I checked Twitter etc. far too often, to the point of it being a distraction, but actually it wasn't a lot of real communication, it was more like people talking at you. I didn't find much "social" value in the whole thing.

I still program Perl for a living, and it'd be nice to see Perl friends, for example, in Frankfurt next year.

About all those CPAN modules - I've looked over the 100+ dists that are under my name on CPAN and have found that most of these I neither use anymore nor do I have any wish to maintain them. Most of them were related to an older work project and are probably not used outside of that.

There are only about six or so dists that I'm really using and maintaining. There are a few modules that others have expressed an interest in maintaining - mostly the Dist::Zilla plugins - and I've given them co-maint.

So, it's no big deal; just curbing my "social" presence.

(Actually, let's see about that Twitter account - as far as I can tell, you can still re-activate it within 30 days, so maybe the addiction might win... :) )

dip script to show DBI queries as they are prepared

There's DBI_TRACE, but sometimes I just want to see the queries that are used in $dbh->prepare(). Here is a simple dip script to do that.

dip -e 'before { warn ARGS(1) } call qr/DBI::.*::prepare/'