Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Perl novice here ;-O

Just installed 5.8 on my Mac OS10.2.4 and getting the Setting locale failed error message:
LC_ALL=(unset) LANG="en_US"
Read about all this in man perllocate, but am confused as to how to permanently fix this problem. Help?

Giving thanks to Superior Monks in advance,

bcathey

Replies are listed 'Best First'.
Re: Setting locale failed error
by pg (Canon) on Mar 10, 2003 at 16:08 UTC
    You can:
    1. either set your locale from your OS, for example on win32, set LANG=”en” (the way you presented is for OS, not for Perl script)
    2. or set from your Perl script, like this: (the code has been tested on win32).
      use POSIX qw(locale_h); use POSIX qw(strftime); use locale; #setlocale(LC_TIME, "en"); #from OS, set your locale to something like + france or Russian, than try to comment/uncomment this, see the diffe +rence. for (0..11) { print strftime("%B", 0, 0, 0, 1, $_, 96), "\n"; }
Re: Setting locale failed error
by zby (Vicar) on Mar 10, 2003 at 15:39 UTC
    Apparently Perl expects to have the LC_ALL locale set (e.g. to "en_US" like the other one). I believe you can set them in some startup script - just add export LC_ALL=en_US. I don't know the startup scripts layout in Mac OS so I can't be more specific.
Re: Setting locale failed error
by janx (Monk) on Mar 10, 2003 at 17:55 UTC
    This is a known deficiency in Mac OS X (darwin i.e.).

    One solution is to set PERL_BADLANG to 0 in your environment, which simply tells Perl to shut up about these sort of locale problems.

    Obviously this could lead to hard to debug problems.
    A better way would be to set your LC_ALL environment var to "C", which is the default locale Perl would use anyway.

    The best (IMHO) way to set this for your own account is to use the following file as your ~/.MacOSX/environment.plist (this sets the environment for every process loaded - without depending on your login shell setting):

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http:// +www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>LC_ALL</key> <string>"C"</string> </dict> </plist>
    Log out, log out and be set.

    Update:
    Don't log out twice ;-) Log in after you log out, of course....grin

    janx