Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Removing comma's from int (numbers)

by farang (Hermit)
on Jun 13, 2013 at 07:30 UTC ( #1038698=note: print w/ replies, xml ) Need Help??


in reply to Removing comma's from int (numbers)

The transliteration (tr) operator could also be used here to avoid the full overhead of regular expressions.

use strict; use warnings; my $grossAmt = "12,345,678.9"; $grossAmt =~ tr/,//d; $grossAmt = sprintf('%.2f', $grossAmt); print $grossAmt, $/; __END__ output: 12345678.90


Comment on Re: Removing comma's from int (numbers)
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-10-02 05:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (49 votes), past polls