Part 1 of a tutorial on Perl 6 Regular Expressions and Grammars

On my blog at The Perl Fisher - Part II coming next week, or whenever I get vectors and lists working in Inline::Scheme::Guile.

Last call for review of Test-Builder using Test2 (Formerly Test-Stream).

On October 29th, 2015, I released Test-Stream as stable. I did this because I felt it was ready, and because I was no longer receiving any feedback from perl-qa asking me to change things. Since that release, the feedback picked up substantially. It seems that declaring something done is the best way to find out ways in which it is not actually done.

Here are the big things people wanted:

  • Split the dist into multiple dists, making the internals and tools separate.
  • Abandon the loader system (use Test::Stream -/:/etc)
  • Loosen the tight coupling of Test::Steam to TAP
  • Make context() less magic (don’t use INTERNALS::SvREFCNT)
  • Use less import() magic
  • Better namespace structuring
  • Changes to how SKIP and TODO are implemented

We decided that the best way forward was to forget about compatibility with Test-Stream, which is still new enough that it is not seeing much use, and make a new name with everyone’s changes. That’s Test2.

After the split there are 3 distributions:

CPAN Weekly: one module per week, in your inbox

CPAN Weekly is a mailing list for Perl 5 programmers. Each week there will be one short message sent to the list, with a brief description of a CPAN module, and example usage.

The idea is not to provide a tutorial, but just to make you aware of the module, and show one basic use case. By planting seeds in your mental Perl toolbox, hopefully next time you have certain needs you will think "oh, I read about a module for that!", rather than "I'll just write a module for that".

You can sign up at

Stupid state trick

Occasionally I find myself writing a Perl subroutine that uses a module that no other part of the code needs. This subroutine may be called multiple times, or not at all. At some point I wondered if putting some logic around the require statement would be faster than just calling it every time. require() is idempotent, after all. You could do something like $counter++ or require Foo;, but the variable has to live somewhere outside the subroutine. Not neat.

It occurred to me that, given Perl 5.10 or greater, something like state $dummy = require Foo; might do the trick. I would be willing to bet this is a use of state that was not anticipated when it was designed. But does it actually do what I want, and is what I want worth doing?

The answer to the first question is "yes." A quick script with require overridden proved that the module was in fact loaded, and that require was called only once no matter how many times it was executed.

How to Make a Perl 6 Module (Bit Rot Thursday)

Happy Bit Rot Thursday! This week I'm taking care of fixing minor issues with packaging of my Perl 6 modules, and so, I'll talk about the general process of releasing a Perl 6 module. Let's dive in!


Perl 6 is a brand new language, so there's yet no well-established module system like what Perl 5 has, but there is a work in progress. Thus, I'll first describe the process for our temporary GitHub-based system and then I'll talk about the PAUSE-based system that's being worked on.

There are some tools and helpers available to help with the process of module development, but they are beyond the scope of this post.

Terms (and no conditions)

Memory savings with cperl and AvSTATIC

B::C and cperl has now proper support for copy-on-grow (COG) and copy-on-write (COW) arrays.

COG means that the array of SV* pointers is allocated by the compiler statically, not dynamically, and that the cperl runtime creates a new array whenever the array is extended (copy-on-grow).

COW means that the array of SV* pointers is allocated by the compiler constant and static in the .rodata segment, and that the cperl runtime creates a new array whenever an element of the arrays is changed (copy-on-write).

With a typical example of a medium sized module, Net::DNS::Resolver, the memory usage is as follows:

pcc -O0 -S -e'use Net::DNS::Resolver; my $res = Net::DNS::Resolver->new;
  $res->send(""); print `ps -p $$ -O rss,vsz`'

with avcow: 12720
without   : 13456

5.8% percent win.

The numbers with a small example are as follows:


What’s in a name? that which we call a rose By any other name would smell as sweet; (William Shakespeare, Romeo & Juliet, Act II Scene ii)

I went to FOSDEM in Brussels this year as a representative of the Perl Foundation. As such I spent the weekend doing my best to be a good advocate of the Perl programming languages.

FOSDEM for those of you in gentle unawareness is probably the world's largest, free, Open Source event. It is held each year in Brussels, Belgium, and attracts speakers for hundreds of talks on dozens of projects, languages and distros. The event is attended by over seven thousand people from almost everywhere in the world.

Focussing Haskell on Perl 6

On the bus ride out to Charleroi I caught a stray brainwave about how to properly notate at least some of Haskell's Lens library, so I wrote up some notes on it. This is going to be slightly spooky, but not much more than the previously-existing ability to bind one data structure to another.

I do want to finish up the Scheme work, if only to prove the crowd on Perlmonks wrong, first though.

The 'lens' library is essentially a metaphor for focussing in on your data, in roughly the following sense:

my $lens =;

$a =< $lens >= $b; # Think of $a "passing through" $lens into $b.
$a = 'foo bar';
is-deeply $b, [ 'foo', 'bar' ];
$b.[1] = 'moo';
is $a, 'foo moo';

Lenses can be chained:

my $lens2 ='-');
$a =< $lens >=< $lens2 >= $b;
$a = 'foo-bar baz-qux';
is-deeply $b, [ [ 'foo', 'bar' ], [ 'baz', 'qux' ] ];

About is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is hosted by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.