YAPC::NA Planning Meeting Tonight

It’s the first Tuesday of the month, so that means it’s YAPC::NA Planning Meeting time. If you’re in the Madison area, or don’t mind a drive there is a YAPC planning meeting tonight at the Essen Haus at 7pm. As always the food and beer are sponsored by Plain Black, and the room is sponsored by Essen Haus.

We’ve got a lot to discuss so the meeting will probably last until around 9pm, but you’re free to come and go as you please.

Introducing DCI to the Perl world.

For those who are not aware, there is a newish methodology called DCI (Data, Context, Interactions) which attempts to solve the problems of OOP. DCI was designed and proposed by the same guy that created the MVC concept that has become hugely successful. DCI is an attempt to group methods with their use cases so that interactions used by business logic and algorithms are more predictable.

The key to DCI is a separation of concepts:

  • Data: what the system is
  • Context: A use case
  • Interactions How objects interact within a context

I have created the DCI dist which includes helpers for writing Contexts and Interactions (DCI uses the terminology roles, but to avoid conflict with other perl concepts of roles I have called them casts.)

The DCI perl package can be found here:

If iframes are supported, this should show the synopsis for a common example of DCI.

Here are some links to information about DCI.

CPAN Testers Summary - August 2011 - Vapor Trails

All was going well last month, we had a few problems balancing the feed and database inserts, but with some help from Devel::NYTProf, we had improved performance and were getting back on top of things. We also had two presentations at YAPC::Europe by myself and Léon, and were heading for 1 million test reports submitted in a single month ... when.....

The CPAN Testers server hard drive developed a fault. Tthis wouldn't have been a problem had the mirrored drive, which had failed earlier in the year been correctly replaced. Alas the first failed drive was still absent, with the second drive failing and switching to read-only mode almost immediately on reboot. As such I had just started to backup in case we lost the drive completely, and then it did fail completely :( Our hosting company required us to accept complete data loss before replacing the two drives.

Shebangs with perlbrew aliases and EUMM (and without local::lib)

I wanted to comment on kevin spencer's perlbrew intro but my blabbering grew so long I chose to make a separate post instead.

shebangs

I used to use the #!/usr/bin/env perl trick for shebangs until (when reading about packaging executables with dists) I learned that ExtUtils::MakeMaker (and Module::Build) will automatically rewrite a full-path shebang to point to the interpreter used during install, but it specifically does not do this with the env trick.

I inadvertently combined 'env perl' with local::lib once and found that the script (reachable from my local::lib bin/) would die because I was trying to run a script in my path with a perl that didn't have that module installed (I must have switched perls in the meantime).

cPanel is one of those critical pieces of infrastructure that...



cPanel is one of those critical pieces of infrastructure that you often don’t think about, but that makes the world a better place for so many people. It’s available from web hosts around the world to make hosting a painless point and click experience rather than a frustrating conundrum of editing config files. 

I’m pleased to announce that cPanel is our first Diamond Level Sponsor for YAPC::NA 2012. And they’re also hiring!

Why work at cPanel?

We speak Perl

cPanel & WHM is developed in Perl. cPanel has and will remain a proud supporter of the Perl community. At cPanel, we welcome both seasoned Perl Developers and promote internal advancement of learning Perl through various venues such as attending YAPC::NA, in house training, Perl Mongers and working side by side with Perl experts.



Benefits

Perl testing with Jenkins/Hudson: avoiding some pitfalls

Having continuous integration is incredibly helpful and setting up a Jenkins server is surprisingly easy. However, configuring Jenkins to run your Perl unit tests is a wee bit harder, although it may seem easy at first. Here are a couple of issues I ran into and some things I learned:

We all know that Perl unit tests, aided by Test::More and prove produce results in TAP format. But since Jenkins is Java and someone once dictated that Java shall only read XML and only write XML, Jenkins expects test results to conform to the JUnit XML format. Well, OK, if they want XML, let's give them XML. So you turn to your favorite search engine and ask it how to transform TAP to JUnit. You will, of course, find something. And since that something was actually written by Justin Mason of SpamAssassin fame, you stop searching at that point and download that conversion script.

Dan's updates for two weeks ending Sept 4, 2011

Last week was a short week for me because I was doing a lot of work up at camp for the Scouts. So here's a two-week update:

TPF:

  • I've been learning a lot about "Level 2" and "Level 3" credit card transactions.   It turns out that when you start handling corporate and government issue credit cards through your gateway, the rules change.   And, if you don't comply with those rules, you end up paying a lot of money!
  • That prompted me to check into how much money we're paying in transaction fees, and I manage to get the bank to drop those rates for us.   JT Smith has also been checking around with other gateways to try to find us an even better rate.
  • The Perl 5 Core Grant fund now has 5 donors that have set up monthly recurring donations via donor.com.   So far, we've collected about $1,200 from non-corporate donations.

PPW :
  • Things are really coming together now.  Several sponsors have sent in their money recently, and we now have enough talks to put on an event.  By the time this blog is published, I hope to have the schedule published.

MOPing with Moose

I’ve used Moose regularly now for a couple years, but really only so far as most people do, as a handy accessor generator and type checker. But my most recent project has called on me to delve, first into Roles, which are a lovely way to teach old classes new tricks, but I found I wanted to do deeper magic…

Now, as I wrote about before, my project is a Node.js style event system for Moose. Moose classes have two types of things associated with them, attributes and methods.

I allow users to declare that their class will emit a particular event through a helper method. You just write:

has_event 'connected';

Vim vs Emacs

This contest is a no-holds-barred match, and is scheduled for one fall. In the corner to my left, hailing from vim.org and weighing in at an awkwardly anemic 9.1MB - Vim! In the corner to my right, hailing from gnu.org and weighing in at a morbidly obese 46MB - Emacs! 

At YAPC::NA 2012, we will once and for all declare a definitive winner in the decades old battle between Vim and Emacs! Two editors go in, but only one comes out. Be there to witness this history making event!

The volunteers - VIPs every event need

An event can't be done without them and every organizer ist happy when there are lots of these people - the volunteers.

Only a few minutes after the announcement that we host YAPC::EU 2012 some people came to me to offer their help...

Getty will do all the social media stuff, Wendy offered to help at the event (help with registration desk, help people to find the rooms, ...), and Steffen, Roman, and Gabi offered to help with stuff that can be done remote.

There is enough to do :-)

We'd like to say thanks in advance. You rock!

Looking up the location of an IP address

This review of perl modules for looking up the location of an IP address is now hosted elsewhere.

Using modules that are not installed

Yesterday I stumbled across an error message of perl5 I've never seen before:

Can't locate loadable object for module X in @INC

I was trying to test a module A that uses a module B that isn't installed. The perlmonks told me that it had something to do with DynaLoader.

I already had a

use lib "'MODULEB/blib/lib";

in my setup.

What made it work was an additional

use lib "'MODULEB/blib/arch";

The reason is that module B is XS based and results in a moduleb.so. DynaLoad looks for this moduleb.so and is only able to find it if the "arch"-directory is in @INC.

Since the application has lots of modules that use each other, I've come with the following snippet I include in every test:


BEGIN {
  my $fh;
  # this is the directories where all modules are in seperate directories
  my $dir = '..';
  opendir($fh, $dir) || die "can't opendir $dir: $!";
  my @entries=sort readdir($fh);
  closedir $fh;

  # get rid of '.' and '..'
  @entries= grep { /^[^.]/ } @entries;

  # add the directory name to get a name we can give 'use'
  @entries= map { "$dir/$_" } @entries;

  # we only want directories ...
  @entries= grep { -d } @entries;

  # expand @INC
  for my $dir (@entries) {
  # Perl-only modules
  eval "use lib '$dir/blib/lib'";

  # modules with XS
  eval "use lib '$dir/blib/arch'";
  }
}

That naturally gives me a quite impressive @INC.

This is a shot of the Distance Education Room 235 in the Pyle...



This is a shot of the Distance Education Room 235 in the Pyle Center where some of the talks for YAPC::NA 2012 will take place.

cmd to compare contents of two directories

diff -qr dir1 dir2

Making RESTful Dancing easy with Dancer::Plugin::REST

An useful plugin for writing RESTful Dancer web applications is Dancer::Plugin::Rest by Alexis Sukrieh, available at https://metacpan.org/module/Dancer::Plugin::REST.

To use it when defining routes, easily:


package MyApp;

use Dancer;
use Dancer::Plugin::REST;

This exports the resource keyword, which can be used as such:


resource camel => (
create => sub {},
get => sub {},
update => sub {},
delete => sub {},
);

This automatically creates the following route handlers:

  • post /camel (create)
  • post /camel.:format (create)
  • get /camel/:id (read)
  • get /camel/:id.:format (read)
  • put /camel/:id (update)
  • put /camel/:id.:format (update)
  • del /camel/:id (delete)
  • del /camel/:id.:format (delete)

The format param can be used in requests such as


GET /camel/larry.xml

Next to that, this module exports a whole bunch of error handler methods, such as

  • status_unauthorized
  • status_ok
  • status_length_required
  • status_not_found
  • status_forbidden

which can be used to make life easier:


return status_unauthorized("Not Larry") unless $user->is_larry;

Logging wide characters with Log4perl

I gave my "Surviving Perl Unicode" tutorial at the Mad Mongers this weekend. After I mentioned Test::Builder's Unicode issue, JT Smith asked how I would silence wide character warnings from Log::Log4perl. I'd never really thought about it.

For instance, here's an easy program that wants to output U+2020 (ᴅᴀɢɢᴇʀ):

use utf8;
use strict;
use warnings;

use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init( level => $DEBUG );

DEBUG( 'Is this a † I see before me?' );  # warning

I get this warning:

Madison Children's Museum

Madison Children's Museum :

If you think you might bring your kids with you to Madison and make a vacation out of your trip to YAPC, then one thing you have got to see is the Madison Children’s Museum. They have amazing hands on demonstrations, art projects, and fun activities. At only $8 per person for a whole day, it’s an inexpensive way to have some fun with the family.

MetaCPAN August Roundup

August was another busy month for MetaCPAN, so I think a recap is in order. I'll proceed chronologically.

2011-08-01

Gabor Szabo included MetaCPAN in his first issue of the Perl Weekly. It's an excellent aggregation of all Perl things blog and newsworthy. I can tell you just from the time involved in a MetaCPAN recap that Gabor is spending a huge amount of time on his weekly newsletters. I follow a lot of blog posts, but I find his weekly recap helps me find interesting stuff I may have missed.

2011-08-03

On Unicode and Sorting

Tom Christiansen published an article on Perl.com on the topic of sorting and unicode.

It's good and it explains a little bit about why Unicode is so difficult and why sorting Unicode (or even ascii) is even more difficult, mainly because it depends on your local definitions what results you expect from a sorting operation.

It might be nice to point out that the modules he proposes on using, Unicode::Collate, and Unicode::Collate::Locale, have been in core perl since 5.8 and 5.14, respectively.

Happy sorting!

CPAN Testers Server Failure

Unfortunately the CPAN Testers server has a failing hard disk, which is only allowing READONLY mode access. As such, all CPAN Testers operations are now failing.

The host company has confirmed that ...

a) our disk has a fault
b) we don't have a second RAID disk (even though we're paying for it!)

As such to replace the disk it requires complete data loss!

As you might anticipate this is not making me happy today. I had already started making plans to migrate to a new server, but to do this gradually over the next month. However, it looks like this will need to be sped up.

As things stands the CT server is effectively out of action. I have read access, but will need to wait until the new server is ready before I can copy over everything as it currently stands. Although I have several backups of data, I would rather avoid rebuilding the complete set of data files.

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.