Test-Simple Release-Candidates

This is an update to the ongoing efforts to update Test-Builder. At this point the updates have been merged into blead, that means the new Test-Simple will be part of perl-5.22, barring any significant reasons to remove it. This post is to provide details you should probably know.

The changes have entered the release-candidate stage. The plan at the moment is to go stable if we have an entire blead-cycle without any significant changes needed. What constitutes a significant change? This is a grey area, obviously documentation, version number, and error message typo fixes are not significant. Logic changes on the other hand can be, at the moment I am relying on discussion with the toolchain-gang and the perl-qa group to make this call.

Pod::Readme can now be used with Dist::Zilla

I've recently released a new version of Pod::Readme with hooks to work with Dist::Zilla.

I also worked with Fayland 林 so that Dist::Zilla::Plugin::ReadmeFromPod will use Pod::Readme.

This means that you can use Pod::Readme's POD syntax in your module for generating README files. This includes the ability to:

  • Write POD sections in your module that are only shown in the README, such as the installation instructions, prerequisites, etc.;
  • Exclude other POD sections from the README, such as the details of functions and methods in your module;
  • Include the module's version, latest changes, or prerequisites in the README automatically;

You can also generate README files in alternative formats, such as POD, markdown or HTML.

Day 6: Think globally, act localizably (File::umask, Locale::Tie, Unix::setuid)

About the series: perlancar's 2014 Advent Calendar: Introduction to a selection of 24 modules which I published in 2014. Table of contents.

Local variables or dynamic scoping is a very nifty feature of Perl that nowadays do not exist in a lot of other languages. It allows you to temporarily set the value of a global variable during a block/scope during runtime, effectively localizing global variables. For example, even though some modules provide configuration settings as global variables, like Data::Dump's $INDENT, you can change the values of these variables without having a global effect by using local:

{
    local $Data::Dump::INDENT = ""; # disable indenting
    $res = Data::Dump::dump(...);
};
# here the value of $Data::Dump::INDENT is restored the original value

Day 5: Look ma, no 'argument list too long'! (App::rmhere)

About the series: perlancar's 2014 Advent Calendar: Introduction to a selection of 24 modules which I published in 2014. Table of contents.

If you spend enough time on a Unix/Linux shell, sooner or later you'll be faced with the task of removing files in a directory that contains a lot of those files (in my case, it's usually a Maildir with lots of spam/unread emails). The directory will contain so many files (like 50k or even millions) that doing rm * will fail with the annoying "Argument list too long" message because the * wildcard is expanded by the shell into a multimegabyte list that doesn't fit into the readline buffer. To delete the contents of this directory you will have to resort to some tricks, like using xargs -n, or going up one level, deleting the container directory, and later recreating it.

The patch -p2 hackathon in Lyon is over

patch -p2 was held in Lyon, in the local Booking.com office, and organized by the French Perl Mongers.

It was the sixth hackathon the French Perl Mongers organized in three years (we're now on a steady "two hackathons a year" rythm), following the Perl QA Hackathon 2012, Quack and Hack Europe 2012, patch -p0, patch -p1, and the Perl QA Hackathon 2014.

Using Role as Partial Classes

For Veure, my text MMORPG, I found myself worrying about the Character class turning into a god object. At over 2,300 lines, 105 methods, and growing, it was getting hard to keep track of everything. I want my code to be clean and easy to follow. As a result, when new behavior arose, I started thinking of other places to put behavior, and wound up with abominations like this:

if ( $missions->has_misssion_for( $character, $npc ) ) {
    ...
}

If you're not familiar with the terminology, NPC stands for "non player character" and, as you might guess, they're implemented via the same class as player characters. So what does the above code do? Does it mean that your character has a mission for an NPC? Does it mean that an NPC has a mission for your character? Does it mean that your missions have a mission for ... wait, what does that even mean? The last one, though, is the natural reading of the above.

All because I was trying to limit the size of the Character class.

Day 4: Date calculator shell (App::datecalc)

About the series: perlancar's 2014 Advent Calendar: Introduction to a selection of 24 modules which I published in 2014. Table of contents.

My habit for the past decade or so, back when I started learning Ruby, is to use irb (the interactive Ruby shell) as a calculator. I guess one can also use python, but irb was the one that stuck in my muscle memory. perl does have the interactive debugger perl -dee since forever, but by default it does not print the result of expressions. I am recently trying to change that habit though and use Reply instead. It's nice, with colors and all (especially with the DataDumpColor plugin).

Sometimes though, instead of numeric arithmetics or string operations, I want to do some date calculations. For example, what is the date (and day of week) 20 days from today? What's 2013-09-01 plus 40 weeks?And so on. Having to write a short script e.g. loading DateTime and creating DateTime object and all that seem so cumbersome.

Use Ctrl-d!

Due to recent events, we now broadcast a public service announcement:

Stop typing "exit" or "logout" to quit your current shell session!

Thank you for your attention - we now return to our regular programming.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is run by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.