affect the decimal point in output, by Jarkko.
p4raw-id: //depot/perl@28965
There is no double interpolation in Perl, so the C<$100> is left as is.
+By default floating point numbers substituted inside strings use the
+dot (".") as the decimal separator. If C<use locale> is in effect,
+and POSIX::setlocale() has been called, the character used for the
+decimal separator is affected by the LC_NUMERIC locale.
+See L<perllocale> and L<POSIX>.
+
As in some shells, you can enclose the variable name in braces to
disambiguate it from following alphanumerics (and underscores).
You must also do
Equivalent to C<print FILEHANDLE sprintf(FORMAT, LIST)>, except that C<$\>
(the output record separator) is not appended. The first argument
of the list will be interpreted as the C<printf> format. See C<sprintf>
-for an explanation of the format argument. If C<use locale> is in effect,
-the character used for the decimal point in formatted real numbers is
-affected by the LC_NUMERIC locale. See L<perllocale>.
+for an explanation of the format argument. If C<use locale> is in effect,
+and POSIX::setlocale() has been called, the character used for the decimal
+separator in formatted floating point numbers is affected by the LC_NUMERIC
+locale. See L<perllocale> and L<POSIX>.
Don't fall into the trap of using a C<printf> when a simple
C<print> would do. The C<print> is more efficient and less
=back
-If C<use locale> is in effect, the character used for the decimal
-point in formatted real numbers is affected by the LC_NUMERIC locale.
-See L<perllocale>.
+If C<use locale> is in effect, and POSIX::setlocale() has been called,
+the character used for the decimal separator in formatted floating
+point numbers is affected by the LC_NUMERIC locale. See L<perllocale>
+and L<POSIX>.
=item sqrt EXPR
X<sqrt> X<root> X<square root>
=back
+=head2 Examples
+
+The LC_NUMERIC controls the numeric output:
+
+ use locale;
+ use POSIX qw(locale_h); # Imports setlocale() and the LC_ constants.
+ setlocale(LC_NUMERIC, "fr_FR") or die "Pardon";
+ printf "%g\n", 1.23; # If the "fr_FR" succeeded, probably shows 1,23.
+
+and also how strings are parsed by POSIX::strtod() as numbers:
+
+ use locale;
+ use POSIX qw(locale_h strtod);
+ setlocale(LC_NUMERIC, "de_DE") or die "Entshuldigung";
+ my $x = strtod("2,34") + 5;
+ print $x, "\n"; # Probably shows 7,34.
+
=head1 NOTES
=head2 Backward compatibility