Want comma in printed numbers not dot. How?

Discussion in 'Perl Misc' started by moller@notvalid.se, Jul 5, 2004.

  1. Guest

    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
    , Jul 5, 2004
    #1
    1. Advertising

  2. Peter Scott Guest

    In article <>,
    writes:
    >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.

    --
    Peter Scott
    http://www.perldebugged.com/
    *** NEW *** http://www.perlmedic.com/
    Peter Scott, Jul 6, 2004
    #2
    1. Advertising

  3. (Peter Scott) wrote:

    > 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

    --
    #!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
    # matlab comment stripper (strips comments from Matlab m-files)
    s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;
    Peter J. Acklam, Jul 6, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guru
    Replies:
    1
    Views:
    6,899
    Michael Borgwardt
    Jul 30, 2004
  2. Samuël van Laere

    To dot or not to dot?

    Samuël van Laere, Oct 16, 2003, in forum: HTML
    Replies:
    8
    Views:
    414
    Samuël van Laere
    Oct 16, 2003
  3. Christopher M. Lusardi

    volatile struct in dot h vs dot c

    Christopher M. Lusardi, May 11, 2004, in forum: C Programming
    Replies:
    3
    Views:
    464
    Peter Shaggy Haywood
    May 15, 2004
  4. Nathan Sokalski
    Replies:
    11
    Views:
    689
    AAaron123
    Aug 14, 2009
  5. Replies:
    6
    Views:
    230
    Thomas 'PointedEars' Lahn
    Dec 12, 2005
Loading...

Share This Page