Archive

Archive for February, 2011

Perl Programming Best Practices LCA 2011

February 6, 2011 Leave a comment

The first linx.conf.au videos are available online. From watching the talk Perl Programming Best Practices, here are some modules and suggestions mentioned in the talk as notes to myself:

  • Always add use strict and use warnings.
  • use autodie allows omitting the or die statements for catching errors.
  • given/when is analogous to switch/case in other languages.
  • say prints a line while automatically adding the newline.
  • Try::Tiny is a CPAN module for try/catch style exception handling.
  • carp and croak should be used to report errors in modules. It is more useful to see where wrong data was passed to the module function, than the exact place where the module called die.
  • App::perlbrew allows installing perl in the home directory.
  • local::lib helps installing perl modules in local directories.
  • Test::More is a module for running tests.
  • Devel::Cover can be used to measure the code coverage.
  • Perltidy reformats perl code to make it easier to read.
  • List::Util has some helper functions for lists (e.g. max, min, sum)
  • Named captures in regular expressions allow using named variables instead of $1, $2, … to extract parts of the original string.

This list is incomplete, and i would highly recommend watching the talk to see everything mentioned there.

Advertisements
Categories: programming Tags: