|
||||||
| Perl Discussion for the PERL language - Practical Extraction and Reporting Language, is a programming language often used for creating CGI programs. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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?
__________________
I Need Help |
| Sponsored Links |
|
|
|
|||
|
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;
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
| Xav | ........ | 1357.94 |
| MeTh0Dz|Reb0rn | ........ | 1075.89 |
| WingedPanther | ........ | 919.18 |
| marwex89 | ........ | 906.86 |
| morefood2001 | ........ | 900.18 |
| John | ........ | 890.77 |
| Brandon W | ........ | 770.65 |
| chili5 | ........ | 312.39 |
| Steve.L | ........ | 264.99 |
| dcs | ........ | 232.34 |
Goal: 100,000 Posts
Complete: 83%