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