Search code examples
linuxperlunixmessagestderr

Avoiding "Setting Locale Failed" Message While Calling Perl


Whenever I run my code:

$perl my_any_code.pl 

It always gives me this:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "C"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

How can I avoid that?


Solution

  • UTF-8 is not a locale name. Set the LC_CTYPE environment variable to a locale that's recognized by your system. It should probably look like en_US.UTF-8. You can get a list of valid locales by running the command locale -a.