Using POSIX
module, I can get current locale value in perl
:
$ LC_ALL=vi_VN.utf8 perl -MPOSIX=setlocale,locale_h,LC_ALL -le 'print setlocale(LC_ALL)'
LC_CTYPE=vi_VN.utf8;LC_NUMERIC=C;LC_TIME=vi_VN.utf8;LC_COLLATE=vi_VN.utf8;
LC_MONETARY=vi_VN.utf8;LC_MESSAGES=vi_VN.utf8;LC_PAPER=vi_VN.utf8;LC_NAME=vi_VN.utf8;
LC_ADDRESS=vi_VN.utf8;LC_TELEPHONE=vi_VN.utf8;LC_MEASUREMENT=vi_VN.utf8;
LC_IDENTIFICATION=vi_VN.utf8
But if I set locale to POSIX
, perl
print C
instead of POSIX
:
$ LC_ALL=POSIX perl -MPOSIX=setlocale,locale_h,LC_ALL -le 'print setlocale(LC_ALL)'
C
Is this default behavior of perl
or I have made some mistakes?
The POSIX
locale is an alias for the C
locale. Presumably on your system, setlocale(..., "POSIX")
sets the locale to C
, and you get that name back instead of the one you passed in.