6 $Carp::Internal{ (__PACKAGE__) } = 1;
10 locale - Perl pragma to use or avoid POSIX locales for built-in operations
14 @x = sort @y; # Native-platform/Unicode code point sort order
17 @x = sort @y; # Locale-defined sort order
19 @x = sort @y; # Native-platform/Unicode code point sort order
24 This pragma tells the compiler to enable (or disable) the use of POSIX
25 locales for built-in operations (for example, LC_CTYPE for regular
26 expressions, LC_COLLATE for string comparison, and LC_NUMERIC for number
27 formatting). Each "use locale" or "no locale"
28 affects statements to the end of the enclosing BLOCK.
30 See L<perllocale> for more detailed information on how Perl supports
33 On systems that don't have locales, this pragma will cause your operations
34 to behave as if in the "C" locale; attempts to change the locale will fail.
38 # A separate bit is used for each of the two forms of the pragma, as they are
39 # mostly independent, and interact with each other and the unicode_strings
40 # feature. This allows for fast determination of which one(s) of the three
41 # are to be used at any given point, and no code has to be written to deal
42 # with coming in and out of scopes--it falls automatically out from the hint
45 $locale::hint_bits = 0x4;
46 $locale::not_chars_hint_bits = 0x10;
49 shift; # should be 'locale'; not checked
51 my $found_not_chars = 0;
52 while (defined (my $arg = shift)) {
53 if ($arg eq ":not_characters") {
54 $^H |= $locale::not_chars_hint_bits;
56 # This form of the pragma overrides the other
57 $^H &= ~$locale::hint_bits;
62 Carp::croak("Unknown parameter '$arg' to 'use locale'");
66 # Use the plain form if not doing the :not_characters one.
67 $^H |= $locale::hint_bits unless $found_not_chars;
71 $^H &= ~($locale::hint_bits|$locale::not_chars_hint_bits);