Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
FS#25600 - [perl] LC_NUMERIC always C
Attached to Project:
Arch Linux
Opened by Silvio Knizek (killermoehre) - Tuesday, 16 August 2011, 10:44 GMT
Last edited by Dave Reisner (falconindy) - Thursday, 18 August 2011, 19:53 GMT
Opened by Silvio Knizek (killermoehre) - Tuesday, 16 August 2011, 10:44 GMT
Last edited by Dave Reisner (falconindy) - Thursday, 18 August 2011, 19:53 GMT
|
DetailsDescription:
In perl LC_NUMERIC is always C and can't be changed, but this is important for my company because in german we use a decimal comma instead of a decimal point (see http://dict.leo.org/forum/viewWrongentry.php?idThread=224942&idForum=7&lang=en). Additional info: * package version perl v5.14.1 Steps to reproduce: compare $ locale | grep LC_NUMERIC with $ perl -MPOSIX -e 'print setlocale(LC_NUMERIC), "\n"' |
This task depends upon
Closed by Dave Reisner (falconindy)
Thursday, 18 August 2011, 19:53 GMT
Reason for closing: Not a bug
Additional comments about closing: see comments, working as intended.
Thursday, 18 August 2011, 19:53 GMT
Reason for closing: Not a bug
Additional comments about closing: see comments, working as intended.
1. You need to use 'use locale' in your program.
2. LC_NUMERIC is always set to 'C'. Now why, I have no idea, but this is an upstream issue, not something we can really deal with, so for any further action on this you'll have to take it there.
setlocale with only one argument (like your example) only queries the current locale. Since it has not been changed yet, it is C. AKA POSIX-compatible. setlocale with a second argument of an empty string ("") will set the locale according to the environment variables of the process. This is the same behavior as the C library function.
In order to set the locale you should use the empty string, like so:
$ perl -MPOSIX -E 'say setlocale(LC_NUMERIC, q{}); printf qq{%0.2f\n}, 3.14'
Here I used -E in order to use say. q{} is the same as '' (the empty string) but helps me to avoid single quotes in bash. qq{} is the same as double-quotes in perl.
Hope that helps.
edit: "use locale" won't help because it only sets LC_CTYPE and LC_COLLATE. For something similar to "use locale", for setting all locale categories, replace LC_NUMERIC above with LC_ALL.