use locale
@x = sort @y; # ASCII sorting order
{
use locale;
@x = sort @y; # Locale-defined sorting order
}
@x = sort @y; # ASCII sorting order againThis lexically scoped pragma tells the compiler to enable (or
disable, under no locale) the use of POSIX locales
for built-in operations. Enabling locales tells Perl's case-conversion
functions and pattern-matching engine to be respectful of your
language environment, allowing for characters with diacritical
markings, etc. If this pragma is in effect and your C library knows
about POSIX locales, Perl looks to your LC_CTYPE
setting for regular expressions and to your
LC_COLLATE setting for string comparisons like
those in sort.
Since locales are more a form of nationalization than of internationalization, the use of locales may interact oddly with Unicode. See Chapter 15 for more on internationalization.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access