Fixing :perl: warning: Setting locale failed." errors on a Debian or Ubuntu system.

The short short version is that I run the following four commands in sequence:

  1. export LANGUAGE=en_CA:en
  2. export LANG=en_CA.UTF-8
  3. locale-gen en_CA.UTF-8
  4. dpkg-reconfigure locales

Of course this example is specific to a Canadian English UTF-8 system. In the US, the language might be defined as something like en_US.UTF-8.