Debugging B::C, gdb into it (part 2)

At the previous entry Debugging B::C, hitting the recursion depth I showed how attack a typical B::C problem, how to use the perl level debugger
stepping into compiling code with Od.

However we found no error in the compiler at a first glance.
Inspecting the generated c code we see for the perl code

package dummy;sub meth{print "ok"};package main;dummy->meth

parts of the optree as

Post!

I really wish more people would post here. I don't want this to be Ovid + the rest of the Perl community. I feel bad about the number of posts I make because I feel like I'm almost dominating this blog.

In other news, I've discovered that using GraphViz and star charts is harder than I thought.

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:

blogs.perl.org Feedback

This site has live been on the new hardware for a while now and things seem to be a lot more stable than they were previously.

There are, however, still a few issues that are left over from the old system and which are causing problems for some users (and some potential users). One particular problem that we keep coming across is that of accounts that were half-created on the old system. If you think you set up an account but you can't log in here or if you log in successfully but the system says you don't have permission to post a blog entry then your account is almost certainly in one of several possible intermediate states.

Most of these issues are really simple to fix. But we can't fix them unless we know about them. We have a ticket tracker on github where you can tell us about these problems. There is a link to this tracker at the bottom of every page on this site.

So if you have a problem of any kind with the site, please use the tracker to left us know about it.

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

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

Thoughts on my Moose lecture

Yesterday I gave a talk on Moose (the post-modern metaclass-based object system for Perl 5) in TelAviv.pm. The slides are available on slideshare. They aren't a lot of slides because I mainly wanted to give an introduction to Moose for beginners and the gist of the lecture is me speaking, so the slides can't really express that.

Now, regarding the talk. There were few people present, which was a bit unfortunate but I'm assuming it's somewhat due to the change in location in the university. It was difficult to find, I have to admit. However, it's a new place, bigger and more comfortable.

If I could do it over again, I would definitely want more people and more participation so we could give some live examples instead of trying to squeeze it out of people. But overall, I'm happy with it.

I scheduled with Gabor to do the lecture on March in Rehovot.pm. If you're near Rehovot, stop by, say hello and learn how to use Moose!

I want to thank Shlomi Fish for organizing TelAviv.pm, the lectures (including this one), the promotion, receiving a free guest room from the university and all the other annoying/difficult things most people don't feel like doing.

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!

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:

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

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)

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:

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.

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.

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.

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:

Bindings for the Enlightenment Foundation Libraries' Elementary

You have another option for GUIs with Perl.

Find it on CPAN.

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.