1locale(3pm)            Perl Programmers Reference Guide            locale(3pm)
2
3
4

NAME

6       locale - Perl pragma to use or avoid POSIX locales for built-in
7       operations
8

SYNOPSIS

10           @x = sort @y;       # Unicode sorting order
11           {
12               use locale;
13               @x = sort @y;   # Locale-defined sorting order
14           }
15           @x = sort @y;       # Unicode sorting order again
16

DESCRIPTION

18       This pragma tells the compiler to enable (or disable) the use of POSIX
19       locales for built-in operations (for example, LC_CTYPE for regular
20       expressions, LC_COLLATE for string comparison, and LC_NUMERIC for
21       number formatting).  Each "use locale" or "no locale" affects
22       statements to the end of the enclosing BLOCK.
23
24       Starting in Perl 5.16, a hybrid mode for this pragma is available,
25
26           use locale ':not_characters';
27
28       which enables only the portions of locales that don't affect the
29       character set (that is, all except LC_COLLATE and LC_CTYPE).  This is
30       useful when mixing Unicode and locales, including UTF-8 locales.
31
32           use locale ':not_characters';
33           use open ":locale";           # Convert I/O to/from Unicode
34           use POSIX qw(locale_h);       # Import the LC_ALL constant
35           setlocale(LC_ALL, "");        # Required for the next statement
36                                         # to take effect
37           printf "%.2f\n", 12345.67'    # Locale-defined formatting
38           @x = sort @y;                 # Unicode-defined sorting order.
39                                         # (Note that you will get better
40                                         # results using Unicode::Collate.)
41
42       See perllocale for more detailed information on how Perl supports
43       locales.
44
45
46
47perl v5.16.3                      2013-03-04                       locale(3pm)
Impressum