in reply to locale savvy comma as decimal operator

I'd suggest looking at perllocale's "Locale Categories" section.

The primary thing to realize is that you can't write numbers as 1.234.567,89 in your program, because you can't change Perl's interpretation of your code. However, if you have data in the form of 1.234.567,89, you can -- as the documentation shows -- use it without error.


Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
  • Comment on Re: locale savvy comma as decimal operator

Replies are listed 'Best First'.
Re^2: locale savvy comma as decimal operator
by diotalevi (Canon) on May 25, 2005 at 22:06 UTC
    I could imagine a fairly simple overload module to make all this work, and work transparently. It'd make runtime slower but if its really desired, its certainly possible.
      Except that commas and periods are used elsewhere in Perl. You'd have to enforce the user employ specific whitespace:
      @array = (1,2,3,4); # would be a syntax error, no? @array = (1, 2, 3, 4); # would be ok
      You'd have to be very careful about the whole thing. I wouldn't even expect Perl 6 to have an easy I18N option about this (but I could be wrong, those Perl 6ers are tough bastards).

      Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
      How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
        For some reason, I thought 1.234,56 would have been parsed as a literal and would be available to overload via %^H to muck with. I just imagined that. Sorry.