Perl 5 Porters Weekly: November 26-December 2, 2012

Welcome to Perl 5 Porters Weekly, a summary of the email traffic of the perl5-porters email list.

Topics this week include:

  • rand() on Windows only uses 15 bits of entropy
  • RFC: Removing several undocumented functions from the Perl core
  • 5.18 VT in \s
  • Comment period extended for Unicode's changing some common characters from Punctuation to Symbol

Silent Night for KephraXP

Yes there are still some (hard to find) bugs, but Kephra, the most curious and perlish editor had a small and silent breakthrough. The new (complete) rewrite is now self hosting and will be from now on used to program Kephra in itself.

Please provide an abstract for posts to blogs.perl.org

When writing on blogs.perl.org, you can provide the first paragraph or two as an abstract, with the rest of your post as the "extended" body. In this post I'll try and convince you that doing this is more considerate of the readership, and good for you too!

Perl community motivation survey - results

Perl community motivation survey is over. Thanks to all those who participated in it!

Here are the results: berekuk.github.com/perl-motivation-survey/.

The results contain various aggregated statistics, as well as the link to the raw data, so I'll spend the rest of this blog post talking about my interpretations and my overall experience from organizing this survey.

YAPC::Europe 2013 in Kiev, week minus 36. A brief update

Dear attendees,

We are very close to signing the contract with the venue. There are a number of things we have to do before we finally sign it. So, please excuse us for doing that so long. We have to negotiate, for example, the place for catering, internet connectivity infrastructure, sound and media equipment, -- all that goes into the contract.

Today I will quote the site of our venue, The Ukrainian House (ukrdim.org.ua, UA). We will rent the following rooms.

Concert hall (782 m²). The room for hosting concerts, literature and art events, congresses, conferences and presentations. It has 490 stationary seats, the stage and a screen. It is equipped with theater, regular and dynamic lightening systems (whatever that means :-) and the 7 kW system of sound amplification. There is a direct connection with the radio studio nearby.

A Look at Cartesian Products

A new post in my blog about Cartesian products.

Problem: You have a number of sets and you want all the combinations when choosing one element from each set.

In mathematics, these combinations are called the Cartesian products. They are also known as cross-products. In the database world, they are sometimes called cross-joins.

Perl case studies

I've often thought it would be interesting and useful to read about how various companies are using Perl. Richard Jelinek's talks at LPW 2012 have encouraged me to see whether (a) there's enough general interest in this to make it worth while, and (b) I/we can kick-start it. In this post I'll outline what I'm currently thinking about, to get feedback.

CGI is dead, long live CGI

Yesterday's (not so pleasant) experience of trying to deploy Pastedance *) on an internal web server at work makes me appreciate the simplicity of CGI. CGI might be out of favor for production sites, but for personal and internal applications, it's still the best choice for me.

Finding Duplicate Code in Perl

When working with legacy code, it's useful to have a variety of tools that let you better understand your code base. For example, I recently wrote about finding unused subroutines. That heuristic approach was fine because I was still going to inspect the code manually rather than automatically remove the code.

So now I hacked out a rough "duplicate code finder" for Perl. It focuses on cut-n-drool code and has found more than I would have thought (even in my code!). If a developer changes variable names, it won't find it, but if I hacked around with B::Deparse, I could fix that, too.

Count-up to 100 CPAN Distributions: Test-XML-Ordered, SDLx-Betweener, and more

Well, it's no longer a secret that I'm craving to join the "100 CPAN Distributions Club" by releasing some code that is hopefully not too useless. Here I would like to blog about the two new additions to my CPAN page which are the 83rd and 84th distributions respectively. The story is a bit more complicated than that.

The first upload is SDLx-Betweener, which allows for creating high-performance and smooth animations in SDL by making use of Perl/XS. Almost all of the coding (and a related YAPC::Israel talk) was done by Ran Eilam, who is a very cool guy, a good friend and a former boss of mine, and I've just done (with his permission) some last-minute cleanups and did the initial upload to CPAN. So I kinda feel like the frog that sat on top of the elephant who crossed the river and said "We did it!".

Moo, how do you annoy me? Let me count the ways...

OK, Moo is actually a rather nice little OO framework. It's inspired by Moose but not a clone of it.

When Moo detects Moose has been loaded, it "inflates" all Moo classes and roles into Moose classes and roles, so Moo code integrates with Moose code perfectly. Because of this, and Moo's very light memory and CPU footprint, many Moose-based projects are migrating to Moo. High profile migrations include Throwable, Message-Passing and MooseX-Role-Loggable.

Not all Moose-based projects are easy to port to Moo. Some require a high level of introspection and meta-hackery that only Moose can provide. But if Moo does seem to be a good fit for your project, switching to Moo is not as simple as dropping the "se" from your "use Moose" lines. There are a number of incompatibilities between the declarative syntaxes of Moo and Moose.

I've recently released MooX-late to help smooth over the differences and translate Moose code to Moo. Currently it handles:

Foswiki tip: How to hide web at the left pane

Rename the web to hide it from left pane. Say the directory is ZAdminTest, rename the folder to zAdminTest

Access it using: http://host/foswiki/bin/view/Main/ZAdminTest/WebHome

I am not sure if this works on *nix system though..

Adding Macros to Excel::Writer::XLSX

Macros are a powerful feature of Excel and are a frequently requested feature for Spreadsheet::WriteExcel and Excel::Writer::XLSX.

It is also a feature that I've wanted to add for some time but it wouldn't be feasible, with current human lifespans, to re-implement Excel's VBA in Perl. So instead I implemented a scheme to "borrow" the VBA code from Excel and add it to an Excel::Writer::XLSX file.

At its simplest an Excel 2007+ file is a collection of XML files in a zip container. Here is a look inside a sample file that contains macros:

Nicer dumping of data structure in Log::Any

When you log data structures with Log::Any, e.g.:

% DEBUG=1 perl -MLog::Any::App='$log' -e '... $log->debugf("ccls=%s", $ccls); ...'

do you often see something like this?

[38] ccls=[{fmt => ['integer','integers'],text => ['integer','integers'],type => 'noun'},{expr => 1,fmt => 
'default value %s',text => 'default value 1',type => 'clause'},{expr => 1,fmt => '%(modal_verb)s be divisi
ble by %s',multi => 1,text => 'must be divisible by 2 and 3',type => 'clause'},{expr => 1,fmt => '%(modal_
verb)s be at least %s',multi => 1,text => 'must be at least 1',type => 'clause'},{expr => 1,fmt => '%(moda
l_verb)s be at most %s',multi => 1,text => 'must be at most 100',type => 'clause'}]

Log::Any uses Data::Dumper with Indent setting of 0. This is compact, but hard to read. Tired of scanning hash keys with my fingers or mouse pointer, I finally spent about 5 minutes creating two patch modules to fix this annoyance. The first one is Log::Any::Adapter::Core::Patch::SetDumperIndent to let you set indent level, and the second is Log::Any::Adapter::Core::Patch::UseDataDump to use Data::Dump instead of Data::Dumper.

For convenience when typing these module aliases are provided: Log::Any::{DD,DI1,DI2,DI3}.

Now you can conveniently do this:

% DEBUG=1 perl -MLog::Any::App='$log' -MLog::Any::DD -e'... $log->debugf("ccls=%s", $ccls); ...'

Perl Oasis 2013: Call for Speakers

The 5th Annual Orlando Perl Workshop, aka Perl Oasis, is coming on January 11th. That's only about a month away. Obviously the organizers are behind on things but they have announced the call for speakers! Please sign up now! If speaking isn't your thing, you can simply come and enjoy the company and geekery. Details are on the website: http://perloasis.info/opw2013/.

MooseX::Role::Loggable improvements (version 0.110)

I've released a new version of MooseX::Role::Loggable: 0.110. It provides some improvements and basically a more steady version of it.

Here's a description of what it is, what the improvements are, and some of the considerations in doing them.

TMTOWTDI, plus benchmarking

There's a very common Perl idiom for getting "top N elements" from an array: @top = (sort @a) [0 .. $n - 1]. Mostly, it's good enough for anything one would dare to store in RAM.

Then, there is Sort::Key::Top, which allows you to write @top = top $n => @a. Yet another syntax sugar?

Not even close! While the docs don't state it boldly, it is:

  1. a XS based module
  2. partition-based general selection algorithm (also known as quickselect) implementation

So, expect it to be fast. How fast?

MooseX::Params::Validate

Subroutines that take more than a single argument should really be using something like MooseX::Params::Validate.

Consider:

sub vivisect { 
    my ( $self, $args ) = @_;
    confess 'Expected a hashref of arguments' unless 'HASH' eq ref $args;

    my $hamster = $args->{hamster};

OK, so we know it accepts a hashref of arguments, and what's more, we know one of them is called hamster. But: what constitutes an acceptable hamster? What do we want to do if we don't have a hamster? What other arguments am I going to need? All of this is mental load at 7am and sure, maybe there's documentation, but maybe the intern snuck in some new options and didn't tell anyone...

Compare and contrast this to:

sub vivsect {
      my ( $self, %params ) = validated_hash( \@_,
          hamster => { isa => 'Hamster', default => sub { Hamster->animate(), } },
      );

Yes, it's some more typing. But now, as a reader, I know what's what. I know a hamster is optional, and I know what'll happen if I don't include it. I know no-one else has been adding other options like guinea_pig, because they'd show up there.

Versioning Loops

I just found something interesting.. well, at least, fun:

Package namespace         installed    latest  in CPAN file
Perl::MinimumVersion           1.29      1.30  CHORNY/Perl-MinimumVersion-1.30.tar.gz

After installing Perl::MinimumVersion, I get:

Package namespace         installed    latest  in CPAN file
Perl::MinimumVersion::Reason      1.20      1.29  CHORNY/Perl-MinimumVersion-1.29.tar.gz

And if I ask to install Perl::MinimumVersion::Reason, yeah, of course, I get:

Package namespace         installed    latest  in CPAN file
Perl::MinimumVersion           1.29      1.30  CHORNY/Perl-MinimumVersion-1.30.tar.gz

Probably a good idea to add a bug report... later.

But fun to have problems with versions on a module that deals with versions.

Perl 5 Porters Weekly: November 19-November 25, 2012

Welcome to Perl 5 Porters Weekly, a summary of the email traffic of the perl5-porters email list. Sorry I didn't publish a summary last week. Although there was list traffic I didn't find any messages I wanted to summarize.

This week's topics include:

  • perl 5.17.6 is now available!
  • On deprecating unescaped literal left brace
  • Parrot 4.10.0 released
  • Perl in Git on Windows?
  • Move tests not using t/test.pl into a separate directory
  • Hash randomisation breaks 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.