locale(3pm)

πŸ’– NAME πŸ’–

okay so bestie, this is locale(3pm) from the Perl Programmers Reference Guide β€” the Perl pragma to use or avoid POSIX locales for built-in operations. periodt.

✨ SYNOPSIS ✨

the whole vibe, code block edition:

my @x1 = sort @y;      # Native-platform/Unicode code point sort order
{
    use locale;
    my @x2 = sort @y;  # Locale-defined sort order
}
my @x3 = sort @y;      # Native-platform/Unicode code point sort order
                       # again

# Parameters to the pragma are to work around deficiencies in locale
# handling that have since been fixed, and hence these are likely no
# longer useful
use locale qw(:ctype :collate);    # Only use the locale for character
                                   # classification (\w, \d, etc.), and
                                   # for string comparison operations
                                   # like '$a le $b' and sorting.
use locale ':not_characters';      # Use the locale for everything but
                                   # character classification and string
                                   # comparison operations

use locale ':!numeric';            # Use the locale for everything but
                                   # numeric-related operations
use locale ':not_numeric';         # Same

no locale;             # Turn off locale handling for the remainder of
                       # the scope.

Quick translation, because iykyk: @x1 is native-platform/Unicode code point sort order, the use locale block flips it to locale-defined sort order, and then @x3 is back to native-platform/Unicode code point sort order again. ✨

Also, the pragma params are there to work around deficiencies in locale handling that have since been fixed, so they're likely no longer useful. Not me pointing at legacy stuff β€” it's literally in the comments. πŸ’€

Here are the params, one by one:

  • use locale qw(:ctype :collate); β€” only use the locale for character classification (\w, \d, etc.) and for string comparison operations like '$a le $b' and sorting.
  • use locale ':not_characters'; β€” use the locale for everything but character classification and string comparison operations.
  • use locale ':!numeric'; β€” use the locale for everything but numeric-related operations.
  • use locale ':not_numeric'; β€” same.
  • no locale; β€” turn off locale handling for the remainder of the scope.

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the actual tea: this pragma tells the compiler to enable (or disable) the use of POSIX locales for built-in operations. Examples? LC_CTYPE for regular expressions, LC_COLLATE for string comparison, and LC_NUMERIC for number formatting. iconic.

Each use locale or no locale affects statements to the end of the enclosing BLOCK. no cap.

And the pragma is documented as part of perllocale. 🫢


that's the whole page, bestie πŸ’– it's from the Perl Programmers Reference Guide, version perl v5.42.3, dated 2026-11-03, and the manual page is locale(3pm) πŸŽ€βœ¨

πŸ“¦ where this page comes from