apeiron: May 2009 Archives

Perl 5 is a vibrant, mature, growing language.

Now that I've said two seemingly incredulous things in as many sentences and have grabbed your attention, I'll continue with this post properly. 

New in Perl 5.10 is the smart match operator (and companion given/when syntax that finally implements switch/case type syntax without a source filter). The issue with this is that there are some edge case bugs with this new functionality. We need as many people hammering at the code as possible to identify all of these edge cases so that they can be fixed for 5.10.1.

Why? I can start with a personal reason. I LOATHE source filters. Nothing makes my blood boil hotter or more quickly than seeing someone use a source filter. They are a disaster for maintainability and introduce indeterminism into an engineering discipline. I have seen the same code using Switch.pm operate differently on two different machines. The smart-match and given/when features in Perl 5.10 provide equivalent (but better) functionality without a source filter. This is good for my blood pressure. There's also the fact that I've wanted this feature in Perl for years without it being a source filter and can finally use it.

But my employer deploys on 5.8.8, not 5.10. This means I don't get to play with this shiny new toy. So anything I can do to convince them to roll out 5.10 makes me a happy coder. Studies easily findable with a Google search show that happier workers do better work and are overall healthier. Therefore, it is in my and my employer's best interests to roll out 5.10.

What about you? Maybe you love the new state variables. Maybe you want to replace Perl's regex engine with the PCRE engine just to annoy me when I go on a rant about how PCRE isn't Perl and why I refuse to answer PCRE questions in Freenode's #perl. Maybe you're like me, a maintenance coder at heart, and you want nothing less than to leave a smoking hole in the universe where Switch.pm used to be.

"But I'm not a tester! I don't know how to test! What can I do?" I'm glad you asked. There's a github repo at http://github.com/rjbs/perl-smartmatch-tests/tree/master which contains a repository of tests and instructions on how to proceed. Take a look at the existing tests (including the just-added failure) to get a feel of how things (don't) work. Be crazy with it. Do things that you're sure should give an error message just to be sure that they do so instead of crashing. Be creative, pathological, and cruel. Apply ~~ to a tied array that randomly deletes its elements upon a FETCH. Try to break it however you can. This is the coolest new feature to make mainstream perl in a long time (since indirect filehandles in 5.6, IMO). I want to be able to deploy (and publish to CPAN) code using this. Surely if you've read this far you want to, as well. 

As some of you may know, I comaintain local::lib with Matt S. Trout. We've had issues with local::lib on Red Hat / CentOS systems in the past. We thought that this was due to Red Hat breaking Perl, because they've had a history of doing so. As some of you may know, I now work at Pobox. They kindly provided me with a MacBook for work purposes. During the process of setting up this MacBook, I installed Perl from MacPorts, because of known issues with users modifying their system's Perl on a commercial Unix OS. In addition to this, I wanted to set up a local::lib environment to make working on Pobox code easier.

Everything was going well with this until I wanted to bootstrap local::lib:

 

    $ perl Makefile.PL --boostrap

    [churn]

    $ ls

    [lack of Makefile]

    # !

    $ perl Makefile.PL --bootstrap

    [churn]

    $ ls

    [presence of Makefile]

 

This behavior is exactly the same as what Red Hat and RH-derived systems exhibit when installing local::lib. Therefore, it seems safe to say that the problem is not Red Hat-specific and warrants an entirely new angle of investigation. I'm going to be pursuing this tonight, but I wanted to make note of my findings here. Like it or not, Red Hat is used a fair deal out in the wild, and getting local::lib to work on it would be a big win (not to mention the fact that I want it to work on the Mac that Pobox is graciously allowing me to use). I'll post here again with progress sometime very soon.

Sponsored By


Ionzero: Rescue your dev project.

Following

Not following anyone

Note to spammers: all comments are moderated. Don't waste your time