Fix the sys/fcntl.h problem reported by Peter Prymmer.
[p5sagit/p5-mst-13.2.git] / pod / perllocale.pod
index 0a85c0e..d37664c 100644 (file)
@@ -124,8 +124,8 @@ B<The POSIX date formatting function> (strftime()) uses C<LC_TIME>.
 
 =back
 
-C<LC_COLLATE>, C<LC_CTYPE>, and so on, are discussed further in L<LOCALE
-CATEGORIES>.
+C<LC_COLLATE>, C<LC_CTYPE>, and so on, are discussed further in 
+L<LOCALE CATEGORIES>.
 
 The default behavior is restored with the S<C<no locale>> pragma, or
 upon reaching the end of block enclosing C<use locale>.
@@ -215,6 +215,8 @@ I<SEE ALSO> section).  If that fails, try the following command lines:
 
         ls /usr/lib/nls
 
+       ls /usr/share/locale
+
 and see whether they list something resembling these
 
         en_US.ISO8859-1     de_DE.ISO8859-1     ru_RU.ISO8859-5
@@ -225,18 +227,18 @@ and see whether they list something resembling these
         english.iso88591    german.iso88591     russian.iso88595
         english.roman8                          russian.koi8r
 
-Sadly, even though the calling interface for setlocale() has
-been standardized, names of locales and the directories where the
+Sadly, even though the calling interface for setlocale() has been
+standardized, names of locales and the directories where the
 configuration resides have not been.  The basic form of the name is
-I<language_country/territory>B<.>I<codeset>, but the latter parts after
-I<language> are not always present.  The I<language> and I<country> are
-usually from the standards B<ISO 3166> and B<ISO 639>, the two-letter
-abbreviations for the countries and the languages of the world,
-respectively.  The I<codeset> part often mentions some B<ISO 8859>
-character set, the Latin codesets.  For example, C<ISO 8859-1> is the
-so-called "Western codeset" that can be used to encode most Western
-European languages.  Again, there are several ways to write even the
-name of that one standard.  Lamentably.
+I<language_territory>B<.>I<codeset>, but the latter parts after
+I<language> are not always present.  The I<language> and I<country>
+are usually from the standards B<ISO 3166> and B<ISO 639>, the
+two-letter abbreviations for the countries and the languages of the
+world, respectively.  The I<codeset> part often mentions some B<ISO
+8859> character set, the Latin codesets.  For example, C<ISO 8859-1>
+is the so-called "Western European codeset" that can be used to encode
+most Western European languages adequately.  Again, there are several
+ways to write even the name of that one standard.  Lamentably.
 
 Two special locales are worth particular mention: "C" and "POSIX".
 Currently these are effectively the same locale: the difference is
@@ -276,10 +278,10 @@ The two quickest fixes are either to render Perl silent about any
 locale inconsistencies or to run Perl under the default locale "C".
 
 Perl's moaning about locale problems can be silenced by setting the
-environment variable PERL_BADLANG to a non-zero value, for example
-"1".  This method really just sweeps the problem under the carpet: you
-tell Perl to shut up even when Perl sees that something is wrong.  Do
-not be surprised if later something locale-dependent misbehaves.
+environment variable PERL_BADLANG to a zero value, for example "0".
+This method really just sweeps the problem under the carpet: you tell
+Perl to shut up even when Perl sees that something is wrong.  Do not
+be surprised if later something locale-dependent misbehaves.
 
 Perl can be run under the "C" locale by setting the environment
 variable LC_ALL to "C".  This method is perhaps a bit more civilized
@@ -287,7 +289,7 @@ than the PERL_BADLANG approach, but setting LC_ALL (or
 other locale variables) may affect other programs as well, not just
 Perl.  In particular, external programs run from within Perl will see
 these changes.  If you make the new settings permanent (read on), all
-programs you run see the changes.  See L<ENVIRONMENT> for for
+programs you run see the changes.  See L<ENVIRONMENT> for
 the full list of relevant environment variables and L<USING LOCALES>
 for their effects in Perl.  Effects in other programs are 
 easily deducible.  For example, the variable LC_COLLATE may well affect
@@ -307,7 +309,7 @@ discussed above.  We decided to try that instead of the above faulty
 locale "En_US"--and in Cshish shells (B<csh>, B<tcsh>)
 
        setenv LC_ALL en_US.ISO8859-1
-       
+
 If you do not know what shell you have, consult your local
 helpdesk or the equivalent.
 
@@ -330,9 +332,9 @@ Second, if using the listed commands you see something B<exactly>
 (prefix matches do not count and case usually counts) like "En_US"
 without the quotes, then you should be okay because you are using a
 locale name that should be installed and available in your system.
-In this case, see L<Fixing system locale configuration>.
+In this case, see L<Permanently fixing your system's locale configuration>.
 
-=head2 Permanently fixing your locale configuration
+=head2 Permanently fixing your system's locale configuration
 
 This is when you see something like:
 
@@ -346,10 +348,10 @@ commands.  You may see things like "en_US.ISO8859-1", but that isn't
 the same.  In this case, try running under a locale
 that you can list and which somehow matches what you tried.  The
 rules for matching locale names are a bit vague because
-standardization is weak in this area.  See again the L<Finding
-locales> about general rules.
+standardization is weak in this area.  See again the 
+L<Finding locales> about general rules.
 
-=head2 Permanently fixing system locale configuration
+=head2 Fixing system locale configuration
 
 Contact a system administrator (preferably your own) and report the exact
 error message you get, and ask them to read this same documentation you
@@ -443,21 +445,21 @@ The following collations all make sense and you may meet any of them
 if you "use locale".
 
        A B C D E a b c d e
-       A a B b C c D d D e
+       A a B b C c D d E e
        a A b B c C d D e E
        a b c d e A B C D E
 
-Here is a code snippet to tell what alphanumeric
+Here is a code snippet to tell what "word"
 characters are in the current locale, in that locale's order:
 
         use locale;
-        print +(sort grep /\w/, map { chr() } 0..255), "\n";
+        print +(sort grep /\w/, map { chr } 0..255), "\n";
 
 Compare this with the characters that you see and their order if you
 state explicitly that the locale should be ignored:
 
         no locale;
-        print +(sort grep /\w/, map { chr() } 0..255), "\n";
+        print +(sort grep /\w/, map { chr } 0..255), "\n";
 
 This machine-native collation (which is what you get unless S<C<use
 locale>> has appeared earlier in the same block) must be used for
@@ -516,8 +518,9 @@ results, and so always obey the current C<LC_COLLATE> locale.
 In the scope of S<C<use locale>>, Perl obeys the C<LC_CTYPE> locale
 setting.  This controls the application's notion of which characters are
 alphabetic.  This affects Perl's C<\w> regular expression metanotation,
-which stands for alphanumeric characters--that is, alphabetic and
-numeric characters.  (Consult L<perlre> for more information about
+which stands for alphanumeric characters--that is, alphabetic,
+numeric, and including other special characters such as the underscore or
+hyphen.  (Consult L<perlre> for more information about
 regular expressions.)  Thanks to C<LC_CTYPE>, depending on your locale
 setting, characters like 'E<aelig>', 'E<eth>', 'E<szlig>', and
 'E<oslash>' may be understood as C<\w> characters.
@@ -551,20 +554,20 @@ change the character used for the decimal point--perhaps from '.'  to ','.
 These functions aren't aware of such niceties as thousands separation and
 so on.  (See L<The localeconv function> if you care about these things.)
 
-Output produced by print() is B<never> affected by the
-current locale: it is independent of whether C<use locale> or C<no
-locale> is in effect, and corresponds to what you'd get from printf()
-in the "C" locale.  The same is true for Perl's internal conversions
-between numeric and string formats:
+Output produced by print() is also affected by the current locale: it
+depends on whether C<use locale> or C<no locale> is in effect, and
+corresponds to what you'd get from printf() in the "C" locale.  The
+same is true for Perl's internal conversions between numeric and
+string formats:
 
         use POSIX qw(strtod);
         use locale;
 
         $n = 5/2;   # Assign numeric 2.5 to $n
 
-        $a = " $n"; # Locale-independent conversion to string
+        $a = " $n"; # Locale-dependent conversion to string
 
-        print "half five is $n\n";       # Locale-independent output
+        print "half five is $n\n";       # Locale-dependent output
 
         printf "half five is %g\n", $n;  # Locale-dependent output
 
@@ -577,11 +580,12 @@ The C standard defines the C<LC_MONETARY> category, but no function
 that is affected by its contents.  (Those with experience of standards
 committees will recognize that the working group decided to punt on the
 issue.)  Consequently, Perl takes no notice of it.  If you really want
-to use C<LC_MONETARY>, you can query its contents--see L<The localeconv
-function>--and use the information that it returns in your application's
-own formatting of currency amounts.  However, you may well find that
-the information, voluminous and complex though it may be, still does not
-quite meet your requirements: currency formatting is a hard nut to crack.
+to use C<LC_MONETARY>, you can query its contents--see 
+L<The localeconv function>--and use the information that it returns in your 
+application's own formatting of currency amounts.  However, you may well 
+find that the information, voluminous and complex though it may be, still 
+does not quite meet your requirements: currency formatting is a hard nut 
+to crack.
 
 =head2 LC_TIME
 
@@ -606,8 +610,12 @@ obeys the current C<LC_TIME> locale.
 
 The remaining locale category, C<LC_MESSAGES> (possibly supplemented
 by others in particular implementations) is not currently used by
-Perl--except possibly to affect the behavior of library functions called
-by extensions outside the standard Perl distribution.
+Perl--except possibly to affect the behavior of library functions
+called by extensions outside the standard Perl distribution and by the
+operating system and its utilities.  Note especially that the string
+value of C<$!> and the error messages given by external utilities may
+be changed by C<LC_MESSAGES>.  If you want to have portable error
+codes, use C<%!>.  See L<Errno>.
 
 =head1 SECURITY
 
@@ -635,14 +643,6 @@ case-mapping table is in effect.
 
 =item *
 
-If the decimal point character in the C<LC_NUMERIC> locale is
-surreptitiously changed from a dot to a comma, C<sprintf("%g",
-0.123456e3)> produces a string result of "123,456". Many people would
-interpret this as one hundred and twenty-three thousand, four hundred
-and fifty-six.
-
-=item *
-
 A sneaky C<LC_COLLATE> locale could result in the names of students with
 "D" grades appearing ahead of those with "A"s.
 
@@ -678,16 +678,22 @@ the locale:
 
 =over 4
 
-=item B<Comparison operators> (C<lt>, C<le>, C<ge>, C<gt> and C<cmp>):
+=item  *
+
+B<Comparison operators> (C<lt>, C<le>, C<ge>, C<gt> and C<cmp>):
 
 Scalar true/false (or less/equal/greater) result is never tainted.
 
-=item B<Case-mapping interpolation> (with C<\l>, C<\L>, C<\u> or C<\U>)
+=item  *
+
+B<Case-mapping interpolation> (with C<\l>, C<\L>, C<\u> or C<\U>)
 
 Result string containing interpolated material is tainted if
 C<use locale> is in effect.
 
-=item B<Matching operator> (C<m//>):
+=item  *
+
+B<Matching operator> (C<m//>):
 
 Scalar true/false result never tainted.
 
@@ -700,7 +706,9 @@ expression contains C<\w> (to match an alphanumeric character), C<\W>
 C<use locale> is in effect and the regular expression contains C<\w>,
 C<\W>, C<\s>, or C<\S>.
 
-=item B<Substitution operator> (C<s///>):
+=item  *
+
+B<Substitution operator> (C<s///>):
 
 Has the same behavior as the match operator.  Also, the left
 operand of C<=~> becomes tainted when C<use locale> in effect
@@ -708,24 +716,30 @@ if modified as a result of a substitution based on a regular
 expression match involving C<\w>, C<\W>, C<\s>, or C<\S>; or of
 case-mapping with C<\l>, C<\L>,C<\u> or C<\U>.
 
-=item B<In-memory formatting function> (sprintf()):
+=item *
 
-Result is tainted if C<use locale> is in effect.
+B<Output formatting functions> (printf() and write()):
 
-=item B<Output formatting functions> (printf() and write()):
+Results are never tainted because otherwise even output from print,
+for example C<print(1/7)>, should be tainted if C<use locale> is in
+effect.
 
-Success/failure result is never tainted.
+=item *
 
-=item B<Case-mapping functions> (lc(), lcfirst(), uc(), ucfirst()):
+B<Case-mapping functions> (lc(), lcfirst(), uc(), ucfirst()):
 
 Results are tainted if C<use locale> is in effect.
 
-=item B<POSIX locale-dependent functions> (localeconv(), strcoll(),
+=item *
+
+B<POSIX locale-dependent functions> (localeconv(), strcoll(),
 strftime(), strxfrm()):
 
 Results are never tainted.
 
-=item B<POSIX character class tests> (isalnum(), isalpha(), isdigit(),
+=item *
+
+B<POSIX character class tests> (isalnum(), isalpha(), isdigit(),
 isgraph(), islower(), isprint(), ispunct(), isspace(), isupper(),
 isxdigit()):
 
@@ -785,9 +799,10 @@ of a match involving C<\w> while C<use locale> is in effect.
 A string that can suppress Perl's warning about failed locale settings
 at startup.  Failure can occur if the locale support in the operating
 system is lacking (broken) in some way--or if you mistyped the name of
-a locale when you set up your environment.  If this environment variable
-is absent, or has a value that does not evaluate to integer zero--that
-is, "0" or ""--Perl will complain about locale setting failures.
+a locale when you set up your environment.  If this environment
+variable is absent, or has a value that does not evaluate to integer
+zero--that is, "0" or ""-- Perl will complain about locale setting
+failures.
 
 B<NOTE>: PERL_BADLANG only gives you a way to hide the warning message.
 The message tells about some problem in your system's locale support,
@@ -806,6 +821,20 @@ for controlling an application's opinion on data.
 C<LC_ALL> is the "override-all" locale environment variable. If
 set, it overrides all the rest of the locale environment variables.
 
+=item LANGUAGE
+
+B<NOTE>: C<LANGUAGE> is a GNU extension, it affects you only if you
+are using the GNU libc.  This is the case if you are using e.g. Linux.
+If you are using "commercial" UNIXes you are most probably I<not>
+using GNU libc and you can ignore C<LANGUAGE>.
+
+However, in the case you are using C<LANGUAGE>: it affects the
+language of informational, warning, and error messages output by
+commands (in other words, it's like C<LC_MESSAGES>) but it has higher
+priority than L<LC_ALL>.  Moreover, it's not a single value but
+instead a "path" (":"-separated list) of I<languages> (not locales).
+See the GNU C<gettext> library documentation for more information.
+
 =item LC_CTYPE
 
 In the absence of C<LC_ALL>, C<LC_CTYPE> chooses the character type
@@ -854,7 +883,7 @@ always in force, even if the program environment suggested otherwise
 (see L<The setlocale function>).  By default, Perl still behaves this
 way for backward compatibility.  If you want a Perl application to pay
 attention to locale information, you B<must> use the S<C<use locale>>
-pragma (see L<The use locale Pragma>) to instruct it to do so.
+pragma (see L<The use locale pragma>) to instruct it to do so.
 
 Versions of Perl from 5.002 to 5.003 did use the C<LC_CTYPE>
 information if available; that is, C<\w> did understand what
@@ -928,44 +957,19 @@ In certain systems, the operating system's locale support
 is broken and cannot be fixed or used by Perl.  Such deficiencies can
 and will result in mysterious hangs and/or Perl core dumps when the
 C<use locale> is in effect.  When confronted with such a system,
-please report in excruciating detail to <F<perlbug@perl.com>>, and
+please report in excruciating detail to <F<perlbug@perl.org>>, and
 complain to your vendor: bug fixes may exist for these problems
 in your operating system.  Sometimes such bug fixes are called an
 operating system upgrade.
 
 =head1 SEE ALSO
 
-L<POSIX (3)/isalnum>
-
-L<POSIX (3)/isalpha>
-
-L<POSIX (3)/isdigit>
-
-L<POSIX (3)/isgraph>
-
-L<POSIX (3)/islower>
-
-L<POSIX (3)/isprint>,
-
-L<POSIX (3)/ispunct>
-
-L<POSIX (3)/isspace>
-
-L<POSIX (3)/isupper>,
-
-L<POSIX (3)/isxdigit>
-
-L<POSIX (3)/localeconv>
-
-L<POSIX (3)/setlocale>,
-
-L<POSIX (3)/strcoll>
-
-L<POSIX (3)/strftime>
-
-L<POSIX (3)/strtod>,
-
-L<POSIX (3)/strxfrm>
+L<POSIX (3)/isalnum>, L<POSIX (3)/isalpha>, L<POSIX (3)/isdigit>, 
+L<POSIX (3)/isgraph>, L<POSIX (3)/islower>, L<POSIX (3)/isprint>, 
+L<POSIX (3)/ispunct>, L<POSIX (3)/isspace>, L<POSIX (3)/isupper>, 
+L<POSIX (3)/isxdigit>, L<POSIX (3)/localeconv>, L<POSIX (3)/setlocale>, 
+L<POSIX (3)/strcoll>, L<POSIX (3)/strftime>, L<POSIX (3)/strtod>, 
+L<POSIX (3)/strxfrm>.
 
 =head1 HISTORY