Month: November 2009

Christmas brings the RJBS Advent Calendar

November 24, 2009 CPAN No comments

*By Ricardo Signes*
Back when I first started learning Perl 5, I was excited to find the [Perl
Advent Calendar]( It was a series of
24 or so short articles about useful Perl modules or techniques, with one new
entry each day leading up to Christmas. A few years later, the Catalyst crew
started the [Catalyst Advent
Calendar]( I always liked
the Perl Advent Calendars, and kept meaning to contribute. Every time,
though there were too many things I’d want to write about — and mostly they
were my own code, so I felt sort of smarmy and self-promoting and never did
Finally, though, I’m glad to say I have tackled those feelings. I will not
shy away from showing off my own code, and I will not worry about having to
choose just one thing. This year, I will publish the [RJBS Advent
Calendar](, 24+ full days of cool, useful, or
stupid code that I have written and given as a gift to the rest of the CPAN
I’ve had a lot of fun working on this project, and it’s helped me find and
fix a number of little bugs or imperfections in the software I’ll be talking
The first door opens in seven days. I hope it’s as fun to read as it was to
write. No returns will be accepted. Approximate actual cash value: $0.02
*Ricardo Signes has written [tons of modules on the CPAN](, including [Dist::Zilla](, the heir apparent to Module::Starter. He is also a total sweetheart, and has a fuzzy head.*

Perl gets modern community blogging platform at

November 20, 2009 Community 8 comments

In a move of unparalleled beauty, Dave Cross and Aaron Crane have announced [](, a modern blogging platform for the Perl community.
Go look. Enjoy the non-ugly color scheme. Marvel at the code syntax highlighting and ability to embed images. Navigate posts using thoughtful categories.
A million thanks to Dave and Aaron for putting this together, and to [Six Apart]( for the design. Links to feeds will be going up here on Perlbuzz as soon as I have time.

Perlbuzz news roundup for 2009-11-17

November 17, 2009 Code craft, Community, CPAN, Perl 5, Perl 6 1 comment

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

  • Pod::Simple 3.09 hits the CPAN (
  • Strawberry Perl and the nightmare of installing Padre (
  • A busy month for masak in Perl 6 (
  • A productive week in Rakudo-land (
  • Perl one-liners explained part III: Calculations (
  • Handy one-liner to lowercase all filenames in a directory: ls | perl -lne’$x=lc;print qq{mv $_ $x}’ | sh -x
  • Use CPAN’s toolchain to improve your code (
  • Future Perl snuck up on me (
  • Find the stupid bug in my progress indicator: say “$n so far” if ( $n % 100000 )”;
  • I maeked u a shell: lolshell, written in Perl 6 (
  • The horrible bug your command line Perl program probably has (
  • Frozen Perl 2010 looking for speakers (
  • apache2rest is a new framework for REST APIs under mod_perl2 (
  • Putting MySQL on a ramdisk to speed up tests (
  • Generating Feedburner graphs ( gets a beautiful upgrade

November 12, 2009 Advocacy, Community, Perl 5 6 comments

Robert Spier writes
> To match the massive advances in Perl over the last few years, has been brought into the modern era. []( has been completely redesigned, making it clearer and easier to use. All the content has been reviewed and brought up-to-date to provide links and other helpful resources for both new and experienced Perl programmers.
> Thanks to []( for donating time from Leo Lapworth, Stephen Morgan, and Cameron Richmond!
Holy cow is it pretty. Thanks to those who made it happen! The [download page]( is especially handy.

The horrible bug your command line Perl program probably has

November 9, 2009 Code craft 4 comments

Most programmers know you have to check return values from system
functions. Unless you’re just starting out as a programmer, you
know that this is bad:

open( my $fh, '<', 'something.txt' );
while ( my $line =  ) {
# do something with the input

If that open fails the program continues on. The call to
readline will fail, return undef as if we’re at
the end of the file, and the user will be none the wiser. If you
have use warnings on, you’ll get a “readline() on closed
filehandle”, but that’s not much help when you should be dying.
Instead, you should be opening your file like this:

my $filename = 'something.txt';
open( my $fh, '<', $filename ) or die "Can't open $filename: $!";

This way, your user gets a useful error message if something goes
wrong, but more importantly, the program doesn’t continue as if
nothing is wrong, potentially doing what it should not.
h2. GetOptions needs checking, too
Unfortunately, I see programs where otherwise-sensible programmers
ignore the return code of GetOptions.

use Getopt::Long;
'n=i' => my $count,
# Do something that uses $count
print "Processing complete!n";

There are any number of ways the user can call this program incorrectly:

$ perl foo -n
Option n requires an argument
Processing complete!
$ perl foo -n=five
Value "five" invalid for option n (number expected)
Processing complete!
$ perl foo -m=12
Unknown option: m
Processing complete!

In all three of these cases, the user made a mistake, but the program
lets it slide without a mention. The user’s going to be disappointed
with the results.
The solution is simple: Always check the results of GetOptions().
The easiest way is to task && exit(1) after the call:

use Getopt::Long;
'n=i' => my $count,
) or exit(1);

It’s simple, effective, and prevents unexpected sorrow.