September 2011 Archives

Perlbuzz news roundup for 2011-09-26

These links are collected from the Perlbuzz Twitter feed. If you have suggestions for news bits, please mail me at andy@perlbuzz.com.

How do you get your Perl news?

| No Comments

Gabor Szabo, the man behind Perl Weekly, is running a poll about how people find out what's going on in the Perl world. Please take a few minutes to fill out this Perl news survey to help Gabor better understand the Perl community and how it keeps track of the Perl world.

The survey is until September 30th, so please respond to the survey today.

Notes from Damian Conway's sessions at OSCON 2011

| No Comments

Here are my notes on two sessions from Damian Conway: The Conway Channel, and (Re)Developing in Perl 6. My notes are scattershot because it's awfully hard to watch and listen and take notes in a Damian. I wish he'd post his slides, but I understand why he doesn't/can't.

(These notes are extracted from my notes from OSCON 2011. Other topics include API design, PostgreSQL, Jenkins and Cornac.

The Conway Channel

The Conway Channel is Damian Conway's annual discussion of new tools that he's created in the past year.

Regexp::Grammars is all sorts of parsing stuff for Perl 5.10 regexes, and it went entirely over my head.

IO::Prompter is an updated version of IO::Prompt which is pretty cool already. It only works Perl with 5.10+. IO::Prompt makes it easy to prompt the user for input, and the new IO::Prompter adds more options and data validation.

# Get a number
my $n = prompt -num 'Enter a number';

# Get a password with asterisks
my $passwd = prompt 'Enter your password', -echo=>'*';

# Menu with nested options
my $selection
    = prompt 'Choose wisely...', -menu => {
            wealth => [ 'moderate', 'vast', 'incalculable' ],
            health => [ 'hale', 'hearty', 'rude' ],
            wisdom => [ 'cosmic', 'folk' ],
        }, '>';

Data::Show is like Data::Dumper but also shows helpful debug tips like variable names and origin of the statement. It doesn't try to serialize your output like Data::Dumper does, which is a good thing. Data::Show is now my default data debug tool.

my $person = {
    name => 'Quinn',
    preferred_games => {
        wii => 'Mario Party 8',
        board => 'Life: Spongebob Squarepants Edition',
    },
    aliases => [ 'Shmoo', 'Monkeybutt' ],
    greeter => sub { my $name = shift; say "Hello $name" },
};
show $person;

======(  $person  )====================[ 'data-show.pl', line 20 ]======

    {
      aliases => ["Shmoo", "Monkeybutt"],
      greeter => sub { ... },
      name => "Quinn",
      preferred_games => {
        board => "Life: Spongebob Squarepants Edition",
        wii => "Mario Party 8",
      },
    }
Acme::Crap is a joke module that adds a crap function that also lets you use exclamation points to show severity of the error.
use Acme::Crap;

crap    'This broke';
crap!   'This other thing broke';
crap!!  'A third thing broke';
crap!!! 'A four thing broke';

This broke at acme-crap.pl line 10
This other thing broke! at acme-crap.pl line 11
A Third Thing Broke!! at acme-crap.pl line 12
A FOUR THING BROKE!!! at acme-crap.pl line 13

As with most of Damian's joke modules, you're not likely to use this in a real program, but to learn from how it works internally. In Acme::Crap's case, the lesson is in overloading the ! operator.


(Re)Developing Perl 5 Modules in Perl 6

Perl isn't a programming language. It's a life support system for CPAN.

Damian ported some of his Perl 5 modules to Perl 6 as a learning exercise.

Acme::Don't

Makes a block of code not get executed, so it gets syntax checked but not run.

# Usage example
use Acme::Don't;

don't { blah(); blah(); blah();

Perl 6 implementation

module Acme::Don't;
use v6;
sub don't (&) is export {}

Lessons:

  • No homonyms in Perl 6
  • No cargo-cult vestigials
  • Fewer implicit behaviours
  • A little more typing required
  • Still obviously Perlish

IO::Insitu

Modifies files in place.

  • Parameter lists really help
  • Smarter open() helps too
  • Roles let you mix in behviours
  • A lot less typing required
  • Mainly because of better builtins

Smart::Comments

  • Perl 6's macros kick source filters' butt
  • Mutate grammar, not source
  • Still room for cleverness
  • No Perl 6 implementation yet has full macro support
  • No Perl 6 implementation yet has STD grammar

Perl 6 is solid enough now. Start thinking about porting modules.

ack 1.96 released, now ignores minified Javascript files

| No Comments

I released ack 1.96 last night. ack is a code searching tool like grep that is tuned for programmers with large trees of heterogeneous source code. Details about ack are at betterthangrep.com.

You can install App::Ack from the CPAN, or follow other instructions at betterthangrep.com.

Details of the update:

  • Now ignores minified Javascript files. Anything matching -min.js or .min.js is ignored.
  • Lua can now get detected from the shebang line. Thanks, Matthew Wild.
  • Added support for version numbers in executables in shebang detection. Now if your Perl program's shebang refers to /usr/local/bin/perl-5.14.1, ack will find it.
  • Added Groovy support (--groovy).
  • Added .pm6 as a --perl extension.

Perlbuzz news roundup for 2011-09-19

| No Comments

These links are collected from the Perlbuzz Twitter feed. If you have suggestions for news bits, please mail me at andy@perlbuzz.com.

Perlbuzz news roundup for 2011-09-12

| No Comments

These links are collected from the Perlbuzz Twitter feed. If you have suggestions for news bits, please mail me at andy@perlbuzz.com.

Perlbuzz news roundup for 2011-09-06

These links are collected from the Perlbuzz Twitter feed. If you have suggestions for news bits, please mail me at andy@perlbuzz.com.

« August 2011 | Main Index | Archives | October 2011 »