locale(3perl)

πŸ’– locale(3perl) β€” the ~vibes~ manual πŸ’–

okay bestie, buckle up, because this is locale from the Perl Programmers Reference Guide, and it's honestly giving "small pragma, big feelings" πŸŽ€

✨ NAME ✨

locale β€” it's a Perl pragma that lets you use or avoid POSIX locales for your built-in operations. that's it, that's the whole name. no cap. πŸ’…


🌸 SYNOPSIS 🌸

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.

like. look at that scope block doing its little thing. the use locale inside the braces is contained, and once you're out, we're back to native-platform/Unicode code point sort order. she's giving ✨localized✨, she's giving "back to normal", she's giving range. πŸ¦‹

also lowkey important: those parameters you can pass to the pragma exist to work around deficiencies in locale handling that have since been fixed, so they're likely no longer useful. historians only. πŸ›οΈ

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea, bestie: this pragma tells the compiler to enable (or disable) the use of POSIX locales for built-in operations. like, for example:

  • LC_CTYPE β€” for regular expressions 🌈
  • LC_COLLATE β€” for string comparison πŸ’¬
  • LC_NUMERIC β€” for number formatting πŸ”’

and here's the scope rule, and it is not optional, it's giving firm boundaries:

each use locale or no locale affects statements to the end of the enclosing BLOCK. that's it. that's the boundary. respect it. 🫢

also, if you want the full lore, the pragma is documented as part of perllocale. go read her, she's iconic. πŸ“š


πŸŽ€ SEE ALSO πŸŽ€

  • perllocale β€” the pragma is documented as part of it, and honestly? main character energy. go look. ✨

and that's the whole page, bestie πŸ’œ this was locale(3perl) from the Perl Programmers Reference Guide, perl v5.44.0, dated 2026-10-17. periodt. go forth and use locale responsibly, mwah πŸ«ΆπŸ’–πŸŽ€

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms