Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Change decimal point temporarily

by fod (Friar)
on Aug 02, 2010 at 22:53 UTC ( #852563=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Change decimal point temporarily
in thread Change decimal point temporarily

Or... I suppose if we have a digit either size of a '.' then it's probably a number with a decimal point:

$s = "123.45"; $s =~ s/(?<=\d)\.(?=\d)/,/;
ALthough... I don't quite understand what you're trying to do - surely if you're parsing a CSV file containing numbers with decimal points you'd rather they weren't commas?


Comment on Re^3: Change decimal point temporarily
Download Code
Re^4: Change decimal point temporarily
by lima1 (Curate) on Aug 02, 2010 at 23:06 UTC
    The motivation is a feature for the module described in RFC: Text::CSV::R. It is an option to set the decimal point. In Germany for example, it is common for CSV files to use a comma as decimal point and a semicolon as field separator.

    So I guess a locale approach would be the performance-wise fastest solution. But setting the locale to an arbitrary locale which uses a comma (de_DE, fr_Fr,...) just to change this single parameter seems like hack.

      I consider using a comma instead of a decimal like that to be a hack in and of itself ... so, when in Rome. ;)


      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)
      

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://852563]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2015-07-05 22:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls