I don't know much about perl and have never really used it. I've got to fix a program though and here is what I need:
The number I get now looks like: 1234567
I need to add two decimals and commas to that number so that it looks like: 12,345.67
Does anyone know how to do this?
if you can assume the last two digits will always will be the decimal part (or the cents):
Code:my $d = 1245678; $d =~ s/(\d{2})$/\.$1/; $d =~ s/\G(\d{1,3})(?=(?:\d\d\d)+(?:\.|$))/$1,/g; print $d;
Thanks! That worked like a charm!
You could always just divide by 100
123232 / 100 = 1232.32
Void
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks