in reply to Formatting MS Access Currency Values
Try this.. it seems to work for me. If (as you said in CB) it'll be an integer this should work.
#!/usr/bin/perl -w use strict; foreach (360000, 12725, 80000) { print "$_ = ".msaccess($_)."\n"; } sub msaccess { my ($num) = @_; $num += 0; while ($num =~ s/(\d)(\d{3})\b/$1.$2/) {}; return "$num,00"; }
Update: The $num += 0; line was added to remove the .0000 off the end. Also tidied up the regexp, thanks to graff's post below for suggesting the \b bit. Never let it be said that I don't maintain my code! :)
Managed to also eventually find Number::Format which seems to handle this kind of thing rather nicely.
|
|---|