Calamitous Context: Stop Breaking My Code!


Perl’s notion of context is a pain, especially with function return values. Even seemingly helpful and innocuous context-sensitive functions can lead to hard-to-spot bugs elsewhere. This talk is a plea for sanity.

After showing examples of different ways in which context can cause subtle problems, and explaining why the recommendations in Perl::Critic and in Damian Conway’s Perl Best Practices don’t entirely help, it contains guidelines for writing Perl that isn’t subject to these hidden flaws, so that you can avoid causing wrath in others.


I gave the same talk at the London Perl Workshop 2012, with essentially the same slides; a video is available on Youtube.

I also delivered an earlier version to Glasgow.pm in February 2012; thanks very much to all the Glasgow.pm members for their comments.