setlocale#

Query or change the program’s locale setting.

Synopsis#

use POSIX qw(setlocale LC_ALL LC_NUMERIC);
setlocale(LC_ALL, "");              # honour environment
my $cur = setlocale(LC_NUMERIC);    # query current

What you get back#

The resulting locale name as a string, or undef if the category/locale combination is invalid. Calling with one argument queries; calling with two sets. Passing "" as the new locale asks libc to pick from LC_* / LANG environment variables.

Edge cases#

  • Changing a category can affect formatting of numbers, collation, date strings, and error messages throughout the process.

Differences from upstream#

Fully compatible with upstream POSIX.

See also#

  • localeconv — inspect the active locale’s numeric and monetary conventions.