Tuesday, June 21, 2011

Use strict AND warnings!

StackOverflow has had severalquestions in the last few days about strict and warnings. Let me say it here definitively:

ALWAYS. USE. STRICT. AND. ALWAYS. USE. WARNINGS.

Until you KNOW when to turn of some fraction of these (e.g. `no warnings 'once'`) and why you are doing it (e.g. `no strict 'refs'), should you do anything except `use strict; use warnings;`!

You really should stop reading here, but if you must, here is some small explaination.

The short reason is, Perl lets you do ANYTHING, and this truly is too much power. These commands save you from the power and from yourself. Don't try to be a hero, you will do something wrong and your code won't work.