Debugging B::C, hitting the recursion depth

The nature of the data driven perl compiler is hitting the perl debuggers recursion limit, even on one-liners.

Consider this bug: [CPAN #53889]
package dummy;sub meth{print "ok"};package main;dummy->meth
=>
ok

The compiler does not detect the meth sub in the dummy package.

  $ perl -MO=C,-DcOACMSGpo,-v,-oa.c -e 'package dummy;
                 sub meth{print "ok"};package main;dummy->meth'
  $ cc_harness a.c
  $ ./a

Can't locate object method "meth" via package "dummy" (perhaps you forgot to load "dummy"?) at -e line 1.

BTW: Easier tested in the distro with
$ t/testc.sh 35

Elegance Fail

Elegance might seem like a lost trait in programming these days, but it is live and vibrant in Perl. A rather large part of the Test namespace is devoted to providing an elegant way to write "run this code, get the result, compare it with this one".

Today I found myself at a loss of an elegant solution to a problem.

I want to run a set of tests. Theoretically I can write each subset of tests as a Role in a test object (there are at least three testing frameworks that allow this nicely) and then run the tests in the object. I can even use MooseX::POE (or regular POE, AnyEvent, Test::Aggregate and the list goes on) to run them asynchronously in order to save the time.

Two things bug me:

Things on my "not" todo list

Silly facebook conversation inspired the following:

package UNIVERSAL::Don't; # Because putting things in UNIVERSAL is fun!'

sub don::t {
    my ( $proto, $method ) = @_;
    my $class = ref $proto // $proto;
    my $method = $proto->can($method) or return;
    *{"$proto\::$method"} = sub {};
    return $method;
}

Just think of how much fun you could have with that ;)

And even though the single quote mark package separator is deprecated, it will be at least a decade before a more strongly worded deprecation notice is added. This, oddly, was inspired by the fact that today at work, I wrote the following package: Don't::Put::Me::In::t::lib:Unless::You::Want::To::Drag::The::Test::Suite::To::A::Screaming::Halt.

And for some reason, this blog is cutting off the rest of that package name, so here it is, broken up: Don't::Put::Me::In::t::lib:Unless::You::Want:: To::Drag::The::Test::Suite::To::A::Screaming::Halt

CPAN upload

CPAN offers multiple ways for uploading modules. I only know of 3 ways:

I'm wondering if it's possible to upload a file through scp (ssh). This would be very convenient in the case where SSH keys would be allowed as it wouldn't require users to type in a password (except for the first time that the ssh-aget loads the key).

Anyone knows if it's possible to use scp?

Padre plugin for Autodia

One of the cool benefits of my new job at Connected-UK is that I get a day a month to hack CPAN/FLOSS projects.

So far, I've done some work on Autodia, Test::HTML::Form and even released two new modules (the latter sponsered by Connected-UK) : Test::HTTP::Response and Padre::Plugin::Autodia

The Autodia plugin for Padre is currently only version 0.01 and very simplistic, but it does allow you to create, view and save UML class diagrams of your code within Padre..

I even had time for some cool screenshots :
Menu (now allows you to do multiple files using the file dialog
A diagram of the current file

yeay!

MSNBOT must die!

If you've suffered any problems accessing any of the sites, the databases, the CPAN mirror, etc from the CPAN Testers server last night, please direct your wrath at Microsoft. Last night the msnbot took out the CPAN Testers server with a dedicated denial of service attack. As a consequence measures are now being put in place to completely ban the msnbot from accessing at least the Reports site, and probably all the sites on the server.

Microsoft in their incompetent wisdom decided to unleash 20-30 bots every few seconds. I know this because I can see the IP addresses in the logs. The ones spotted within a few minutes of rebooting the server this morning to clear the processes were:

65.55.207.50
65.55.207.23
65.55.207.93
65.55.207.25
65.55.207.48
65.55.207.46
65.55.207.72
65.55.207.26
65.55.106.234
65.55.107.179
65.55.207.100
65.55.207.121
65.55.207.30
65.55.207.69
65.55.207.28
65.55.107.180
65.55.207.27
65.55.207.47
65.55.207.21
65.55.207.51
65.55.207.54

Committed to Testing (by accident)

I recently moved to a new BBC team (if we go down, iPlayer goes down too) and am getting used to working in a different environment with different tools. One issue is that certain tools I'm used to working with are not available (Test::Most being the most noticeable) and getting them added to all environments is a bit bureaucratic (all things considered, shipping new tools should be treated with more caution at many shops than it tends to be). Thus, when I accidentally merged to trunk with a test which contained Test::Most, I was embarrassed.

That's when the rather obvious answer occurred to me. I don't want to accidentally commit use of that module, but it's easy to do. Thus, here's how I do it safely:

First blogs.perl.org post

First post on blogs.perl.org, coming from .

Making Dancer Dance on CGI A.K.A. Blog Fix #543

So, last blog entry I mentioned Dancer and that I want to use it as CGI (since it's Plack-aware) but I don't know how.

Nick Spacek commented on my entry saying that if it supports Plack/PSGI, there should be an easy way to run it as CGI.

Later that evening I sat down for hummus with my girlfriend (hummus is awesome, ok?). After talking to her about it, I decided to take a minute to check online on my phone if anyone has any explanations on it. In the first 5 results, I found a post Alexis Sukriah (who wrote Dancer!) wrote that same day, regarding my post, showing how to use Plack to run a Dancer app under CGI!

Case in point:

use Plack::Server::CGI;
use Plack::Util;

my $psgi = '/path/to/your/app/app.psgi';
my $app = Plack::Util::load_psgi($psgi);
Plack::Server::CGI->new->run($app);

... and the web server configuration to use it.
(example shown on Alexis' post)

Cantella::Store::UUID - 0.002000

I've released a new version of Cantella::Store::UUID. (git) It features one incompatible change, but I figured it was OK since I'm pretty sure nobody is using it and it is reasonably new. I just couldn't live with having one lone method named so awkwardly. The POD was all updated and improved and two new methods were added, which allow the user to search for files in the storage directory and perform some action on these files. I don't really intend for these methods to be used a lot, since they will take minutes to run on most systems and be incredibly IO-intensive (depth-first search of the entire storage tree, which could be hundreds of thousands of nodes). I use them mainly for maintenance operations and you should probably too.

Unless what?

You know, I really would love to have a heart-to-knife conversation with developers who use complex unless conditions. While trying to tease apart some code, I came across this gem:

unless ( $blocklist->has_block_with_id( $db_obj->id )
      || ( ! $allow_duplicates 
        && exists $episode_ids->{$db_obj->version->episode_id} ) ) {

To be fair, code grows over time and it's easy to understand how issues like this crop up (and this is a fairly old bit of code), but it took me a while to make sure I understood this. My naive conversion of this to an if statement failed. I had to reduce it down to its simplest components and do a truth table:

Bubbles and Doughnuts and Radar

Spreadsheet::WriteExcel now supports Area, Bar, Column, Line, Pie, Scatter and Stock chart types. I think that I'll leave it at that for now and concentrate on the sub-types within those charts. Bubbles and Doughnuts and Radar will have to wait untill later. Anyone use those?

Here are some example programs with screenshots and here is the output from the Stock example:

stock1.jpg

Hello Clarity

For two weeks we've been working hard on defining a rather complex construct of DNS zone files, using multiple servers for multiple domains with cross referencing them and a lot of other complex-sounding terms.

We wrote DNS tests for the zones to make sure all the servers are configured correctly and the general DNS fetching provides correct information. This turned out to be quite difficult.

The original script is 130 lines. This is without taking into account even more testing we wanted. There was a lot of analyzing done which was rather repetitive and the overall code was ugly and not fun to read (to put it in mild terms). I decided to write a testing module for DNS zones - Test::DNS.

Using Test::DNS, we rewrote the script with a lot more options, which we wanted. The resulting script (with the addons) is 20 lines. It's clean and readable.

Making Module::Starter easier to subclass

I started with what I thought would be a simple Module::Starter subclass. I wanted to modify Module::Starter::Smart, which knows how to add a new module to an existing distribution, to properly handle an existing MANIFEST and MANIFEST.SKIP. I thought I could just override create_MANIFEST (RT 53339). Once I overrode that, however, I wanted to make a couple of additional tweaks, things weren't so easy.

Although I'm using Module::Starter as an example in this post, I could just as easily use one of my own modules to illustrate the same thing. I've just been hacking on Module::Starter for the past week so I can get it into shape for use in the next edition of Intermediate Perl. I'm not a particular fan of the module, but its the best place to start if you don't know you want to use something else.

My problem started when I also wanted to handle some DWIMery in the --dist command-line parameter:

Dear Recruiters

To any and all recruiters who might stumble across this blog entry, here's a useful tip: be courteous.

I'm not looking for work, but I certainly understand why you contact me on LinkedIn or via referrals. That's how you make your money and while some people I know loathe any contact from you, I shrug it off as a fact of life. I am contacted by enough recruiters that I don't remember all of you, but there is one group of you I strive to remember. The email exchange almost always go like this:

You: I have a great opportunity that I think is perfect for you.
Me: I'm not looking for work, but if I were, here are my minimum requirements.
You: ... crickets chirping ...

Excuse me? I admit the fact that I'm not looking for work is not appealing to you. I also admit the fact that the "great opportunity" as a junior developer doesn't fit me. I don't, however, accept that you can initiate a conversation and then not so much as acknowledge my reply once you realize that the huge pay cut you tried to entice me with isn't enticing.

I do remember your name and when you contact me again, I'll remind you why I won't do business with you.

Bindings for the Enlightenment Foundation Libraries' Elementary

You have another option for GUIs with Perl.

Find it on CPAN.

Dependencies and patches - easy fix!

Problem:

I've been upgrading some systems at work recently. Using local::lib so I can test it first without worrying about rolling back being a pain (which it could be with our current build system).

We've had most of our CPAN modules installed for several years and haven't had the need/time to upgrade them. But with the advent of Catalyst 5.8 using Moose and other great projects we'd like to get involved in, such as Gitalist I bit the bullet and started installing into my local::lib so I could then run our tests against it, but then I hit a few problems....

Now remember when I said we had old module? - I'm talking some that haven't been upgraded in 4+ years (they only get upgraded when a newer version is set at a prerequisite).

undeclare.pl: MooseX::Declare -> Moose

Our current project at my job is based solely on rather sophisticated object model, we've chosen MooseX::Declare as one of our main helpers. We are very happy with compiletime argument checks, I guess it saves us a lot of debugging time. Unfortunately our app performance was far from satisfying; the profiling showed it was MXD's fault. Also, we found an enlightening benchmark .

The problem was solved by implementing a tool that allowed us to have two variants of our codebase: development and release. Release is prepared by translating method declarations with method signatures into plain perl subs with parameters parsing. This job is done by undeclare.pl , it uses PPI to parse and transform .pm files.

Some of our domain-specific tests now run more than 10 times faster.

Next QA Hackathon - What Do You Need?

So I hear that the next Perl QA Hackathon will be in Vienna. What should we accomplish? The following is not complete as I was so focused on the areas I was working on that I really didn't follow the other areas.

In the first QA Hackathon, in Oslo, we nailed down a bunch of issues we'd like to see in TAP. We clarified part of the spec and started work on tests for TAP itself. (And convinced Nadim Khemir to release App::Asciio).

The second QA Hackathon, in Birmingham, UK, saw the creation of nested TAP (i.e., subtests).

The third one, I think, should result in either better parsing of nested TAP or shoe-horning structured diagnostics into TAP.

I Gotz Me a Dancer

Sometimes a good time means relaxing with CPAN, reading a POD of something and trying to learn it. At least for me.

Last weekend I treated myself to playing with KiokuDB and Dancer. I'll write on KiokuDB later, this post is on Dancer.

Dancer is a Plack-aware web application framework written by Alexis Sukrieh. It has a built-in simple templating system, but supports Template::Toolkit (a must for me), routes handlers (named matching, regex matching, wildcard matching), simple rapid prototyping and support for multiple configurations and allows separate configurations for separate environments and stages of the software.

After playing with it for a rather short time, I already implemented CRUD. The code comes out clean (which I love), understandable and simple. Pure joy. You should totally check it out!

The only problem is that I want to write an interface which will be hosted on someone else's computer, which only supports CGI. I have no idea how to run it as CGI. Any ideas?

Update: Alexis Sukrieh wrote on how to do this here. Next post will reflect this!

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.