Want comma in printed numbers not dot. How?

M

moller

I thought this wold be simple, but after fooling
around with POSIX and locale I cant get it to
work.

LC_NUMERIC stays C no matter what I try.

Using Activestate perl on WIN-XP Swedish version.
I would apreciate any pointers so that I can
get rid of the
$n =~ y/\./,/;
Im using as a fix now.


I have read perldoc perllocale but no luck
with those examples either.


/moller
 
P

Peter Scott

I thought this wold be simple, but after fooling
around with POSIX and locale I cant get it to
work.

LC_NUMERIC stays C no matter what I try.

Using Activestate perl on WIN-XP Swedish version.

Locale names on Windows are different. This works:

C:\Documents and Settings\peter>perl -MPOSIX=locale_h -Mlocale -le \
"setlocale(LC_NUMERIC, 'French'); print 22/7"
3,14285714285714

where on Unix it would be "fr_FR" instead of "French".

Tested with ActivePerl 5.8.2 on XP.
 
P

Peter J. Acklam

This works:

C:\Documents and Settings\peter>perl -MPOSIX=locale_h -Mlocale -le \
"setlocale(LC_NUMERIC, 'French'); print 22/7"
3,14285714285714

where on Unix it would be "fr_FR" instead of "French".

Neither of them seem to work on Cygwin, though...

$ perl -MPOSIX=locale_h -Mlocale -le \
"setlocale(LC_NUMERIC, 'French'); print 22/7"
3.14285714285714

$ perl -MPOSIX=locale_h -Mlocale -le \
"setlocale(LC_NUMERIC, 'fr_FR'); print 22/7"
3.14285714285714

[This is perl, v5.8.2 built for cygwin-thread-multi-64int]

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top