locale(3p)

locale3p

Perl pragma to use or avoid posix locales for built-in operations

Usage

 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.

Overview

This pragma tells the compiler to enable (or disable) the use of POSIX locales for built-in operations (for example, "LC_CTYPE" for regular expressions, "LC_COLLATE" for string comparison, and "LC_NUMERIC" for number formatting). Each "use locale" or "no locale" affects statements to the end of the enclosing BLOCK.

The pragma is documented as part of perllocale.

Releases

32 releases since OpenBSD 5.0; the text changed 20 times.

  1. 5.0–5.3
  2. 5.4–5.5
  3. 5.6
  4. 5.7
  5. 5.8–5.9
  6. 6.0
  7. 6.1
  8. 6.2
  9. 6.3–6.4
  10. 6.5
  11. 6.6
  12. 6.7
  13. 6.8
  14. 6.9–7.2
  15. 7.3
  16. 7.4
  17. 7.5
  18. 7.6
  19. 7.7–7.8
  20. 7.9
  21. 8.0

From man 8.0-current-20261101 in OpenBSD 8.0-current (2026-11-01). Parsed by carta from the page's man source.