You can:
- 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)
- 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";
}
| [reply] [Watch: Dir/Any] [d/l] |
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. | [reply] [Watch: Dir/Any] [d/l] |
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 | [reply] [Watch: Dir/Any] [d/l] |