From 43b782019117ddeb72a157f262e1009a0bdf57c4 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 15 Aug 2002 00:19:43 +0000 Subject: [PATCH] Added commify. --- lib/WebGUI/Utility.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/WebGUI/Utility.pm b/lib/WebGUI/Utility.pm index d4bd451eb..66c6ed488 100644 --- a/lib/WebGUI/Utility.pm +++ b/lib/WebGUI/Utility.pm @@ -15,7 +15,14 @@ use strict; use Tie::IxHash; our @ISA = qw(Exporter); -our @EXPORT = qw(&randomizeArray &sortHashDescending &sortHash &isIn &randint &round); +our @EXPORT = qw(&commify &randomizeArray &sortHashDescending &sortHash &isIn &randint &round); + +#------------------------------------------------------------------- +sub commify { + my $text = reverse $_[0]; + $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; + return scalar reverse $text; +} #------------------------------------------------------------------- sub isIn {