Get ready for Aspect-Oriented Programming with Aspect.pm

Around Christmas 2009 I took over Aspect.pm, a first-generation implementation of Aspect-Oriented Programming for Perl based on Hook::Lexwrap

Over the last year and a half I've expanded functionality, cut back dependencies to a minimum, optimised the hell out of it, and written a ton of documentation and a comprehensive test suite.

This second-generation implementation has now reached about as far as I can take it without resorting to exotic XS code to replace some of the exotic Perl code. So after a final 2 week sprint to smooth off some ugly corners, in the next few days I'll finally be releasing version 1.00 of Aspect.pm.

I'll be talking more later about some of the more interesting things you can do with Aspect-Oriented Programming. What I'll also be trying to do is focus on actual useful things, and avoiding as many as possible of the utterly batshit insane things that Aspect.pm lets you do.

Perl 6 IRL (In Real Life)

A couple of weeks ago a ran into a real life situation where Perl 6 was able to greatly simplify my life. I was in the process of importing some Canadian postal codes from a PDF document where the data was presented like this:

A0A-A0R,D13
A1A-A1G,D11
A1H-A1M,D13
A1N,D11
A1S-A8A,D13
B0C-B0E,D11
B0H-B0W,D10
B1A-B2E,D11
B2G-B2H,D10

Each postal code, or postal code range, was tied to a zone. To store this to a database, I wanted to expand out each of these ranges to capture each value. Causing the first line to be represented as:

A0A => D13
A0B => D13
A0C => D13
... some more ...
A0R => D13

Using the Perl 5.12 range operator (..) I thought I could use easily accomplish this goal.

App::PipeFilter 0.001 on its way to CPAN

Thanks, everyone who was interested in App::PipeFilter. Your interest motivated me to clean it up and send the very first release to PAUSE. It'll be on CPAN once your favorite mirror catches up. Check out the snazzy documentation, which consumed most of my time since my last announcement.

Patches and pull requests welcome!

Failing your way to success with A/B Testing

So I've read and very carefully considered the words of Douglas Bowman and his decision to leave Google and much of this was about Google's use of A/B testing ... Google's extensive use of A/B testing. Google engineers clearly valued function over form. He complains about a situation where 41 shades of blue were tested for optimum response (see page 3) and makes it clear that he felt constrained. No matter what he did, how simply he did it, he had to "prove" it worked. He simply wanted to build something beautiful and not worry about extreme micromanagement of every aspect.

I can understand that. Many times I want to just "make stuff happen", secure in the knowledge that I know what I'm doing. I look at how foolishly code is implemented and I think "what our customers really want is X!". And A/B testing shows me, over and over again, that I'm wrong. It's humbling. It's humiliating. And if you really care about being the most effective you can be, you'll love it, but only if your pride can handle being proved wrong on a regular basis.

New release of Autodia - now with Mason support

I've uploaded a new version of autodia to PAUSE and it should be available on CPAN shortly.

Highlights of this release are :
* added Mason handler provided by Peter Franke
* new ASP Handler provided by Dalton Mackie
* improved tests (and made some tests author_only)
* A bunch of minor fixes and barely noticable improvements

French Perl Workshop 2011

FPW2011 will be held in "Cité des Sciences et de l'Industrie" Paris,
France on the 24th and 25th of June.

This will be the 8th conferences organized by the French Mongueurs de Perl.
This event will gather Perl's users from all levels, from the beginner to the expert.
This will be an occasion to meet several famous french Mongers.

Share the informations to your colleagues, to your friends, to your HR department,
if you think they can be interested. We hope to welcome you at the Cité des Sciences.

Information and registration: [http://www.journeesperl.fr/]
Contact: contact-fpw at mongueurs dot net

App::PipeFilters gets multiline parsing and JSON::Path

Tonight I added support for multiline JSON input to all the App::PipeFilter tools. This is great for data sources that are beyond one's control, such as those found on the web. But I haven't found one to use as an example, so you get this instead:

% curl -s 'http://search.twitter.com/search.json?q=pipefilters' |
jpath -o '$..from_user' -o '$..text' |
jmap -i col0 -o from -i col1 -o text |
json2yaml

... produces output like this:

--- 
from: perlironman
text: "Rocco Caputo (rcaputo): App::PipeFilters - JSON in the Shell http://bit.ly/mGgnOX"

See what I did there with JSON::Path expressions? The jpath filter can extract fields from deep within JSON objects (but jcut will be faster for simple JSON objects).

Here's another example:

WebGUI 8 Status Report

A major milestone in WebGUI 8 development was reached this week: A dry-run of the WebGUI 8 upgrade was successfully run against the plainblack.com database. This means the only thing remaining from releasing an alpha 8.0.0 is updating all the custom code on http://plainblack.com and http://webgui.org. As always, plainblack.com and webgui.org will be the first sites running the latest bleeding-edge version of WebGUI (unless one of you wants to beat me to the punch).

This month, I also gave a presentation to Madison.PM about building applications in WebGUI 8, a quick introduction to Assets and an overview of the most important changes to how they work. The slides are available at http://preaction.github.com/ and the code samples are linked at the end.

On an unrelated topic, I really enjoyed using S5 to build my slides, SHJS to highlight the code inside, and Github Pages to host the whole thing. I plan on doing the same for all my presentations: They look good, readable without a special program, editable without a special program, anyone can fork and update my presentations, and they're served by a nice, fast, free host.

A note re Set::FA::Element

Hi Folks

Mark Rogaski, the author of Set::FA has kindly given me co-maint, so I can make some changes.

This post really concerns Set::FA::Element, which is what I'm using for the unreleased Graph::Easy::Marpa::Lexer module. The latter module is working (at home) on simple graphs.

Firstly, I'd like to add a method to return what's captured. This simplest patch is to change line 102 from:

my $regex = qr{$rule}; # precompile regex

to:

my $regex = qr{($rule)}; # precompile regex

I.e. To add capturing parentheses, and a method called match() to return the value. Since match($string) sets what matched, you can even fool the DFA via this method...

Because there is not currently any such capability, I'd like to think this doesn't affect too many users, if anyone. But if this does concern you, please comment this post.

Solarized syntax highlighting on search.cpan.org

So, remember Mark A. Stratman’s post about syntax highlighting for search.cpan.org?

You may also be familiar with Ethan Schoonover’s excellent Solarized color palette. If not, go take a quick look; there’s some really nice design and attention to detail over there.

Putting these two things together: I’ve assembled two color schemes from the Solarized palette and submitted them to Mark, and then pestered Graham Barr a bit, and now you can select solarized-dark and solarized-light from the syntax highlighting drop-down menu.

Comments and pull requests welcome :)

-Steve

App::PipeFilters - JSON in the Shell

I've just put App::PipeFilters on github for review before I inflict them on CPAN.

They're a small set of UNIX command line tools for working with structured data. In particular, JSON objects, one per line. They're compatible with many UNIX command line tools like sort and uniq. From the README:

My First Twitter App

Today I finished my first twitter app. My main point in posting this entry is to talk about how wonderful is Perl, and in particular how fancy is Net::Twitter. If you already know these things you can safely stop reading now.

My completed application is two programs each of which appear to be 67 lines long. In addition to providing a feed into Twitter I also threw in a CGI component, just for giggles.

The First Test I Always Write

Nothing fancy, I just find myself copying this test into t/ directory of every new project so I thought others might find it useful, too.

Basically, it just runs Test::More's use_ok() on every file in the package's blib/lib directory to ensure that everything is building okay.

file: 000use.t

use Test::More;
use File::Find;

my @classes = ();

my $root = 'blib/lib';

File::Find::find(
    sub {
        return unless $_ =~ /.pm$/;
        my $path = $File::Find::name;
        $path =~ s|^$root/||;
        $path =~ s|.pm$||;
        $path =~ s|/|::|g;
        push @classes, $path;
    },
    $root
);

ok( scalar( @classes ) > 0 );

foreach my $class ( @classes ) {
    use_ok( $class );
}

done_testing( scalar( @classes ) + 1 );

What's the first test you always write?

Net::VNC update

I've added an interesting feature to Net::VNC: sending key events. You can now use it to automate tasks on remote machines...

Sleep Sort with POE

Sleep sort is described in this silly 4chan thread. I don't guarantee work safety.

It's essentially an insertion sort into time itself. A timer is created for each numeric value to sort, and the order in which they occur determines the outcome.

I've implemented a parallel version using POE.

What's new in Perl 5.14

An English version of my presentation given at YAPC::Russia a few hours before the release of Perl 5.14.

Perl 5.14.0 benchmarks and RPMS

I've been struggling for a while with the issues of deploying Perl applications in enterprise setups for in house Perl applications. So I rolled a couple of RPM spec files for 5.12.3 and 5.14.0 with the eventual goal of being able to deploy Perl applications on RPM based distributions (Fedora and Centos) without needing the system perl binaries to run the app.

I built a couple of RPMs and ran PerlBench on them, 5.14.0 has some nice results:

http://www.redhotpenguin.com/fredperl_bench/

I dubbed my effort 'fredperl' for lack of a better name. If you run Centos or Fedora and have been banging your head against maintenance issues with your app because you are using the system perl binary, I'd love your feedback on my initial effort here:

https://github.com/redhotpenguin/fredperl

Perl 5.14

I've only now realised that Perl 5.14 had been released this weekend. Yay!!

After reading perldelta I'm quite impressed with all the new features etc. I especially like these three:

I'm looking forward to installing the new version in the next few days! (why not now, you might ask: because I sort of broke my left ring finger while doing some shadow boxing with my son, which makes typing a bit complicated)

Why Perl 6 should be spelled roman

Yes it should spelled Perl vi (no pun intended). Just stays for vision. Perl 6 is the most visionary language i know of.

My Main Perl5 Project Is Also My Main Parrot Project

I've been trying to find time to work on parrot-handler, a parrot management tool in the spirit of perlbrew and rvm, for several months now. It's written in Perl 5, and could be very useful indeed. I've just been so busy ...

Well, okay. I've been busy playing World of Warcraft, dabbling with languages that are not based on Parrot, and messing about with my laptop. Oh, and doing work stuff. Still, that's kind of busy.

But there are some Parrot things that I'd like to do, and a working parrot-handler could make those things easier. I think maybe a little less WoW and a little more code tonight.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.