]> granicus.if.org Git - pgbadger/commitdiff
Set thousand separator and decimal separator locale dependant
authorDarold <gilles@darold.net>
Sat, 9 Jun 2012 12:19:18 +0000 (14:19 +0200)
committerDarold <gilles@darold.net>
Sat, 9 Jun 2012 12:19:18 +0000 (14:19 +0200)
pgbadger

index 3c2ad9adb5617943d338853727347756fddc03b4..e31907981d56bee61ac43af307d2fa1e6a54517d 100755 (executable)
--- a/pgbadger
+++ b/pgbadger
@@ -29,6 +29,8 @@ use IO::File;
 use Benchmark;
 use File::Basename;
 use Time::Local 'timelocal_nocheck';
+use POSIX qw(setlocale LC_NUMERIC);
+setlocale LC_NUMERIC, "";
 
 $VERSION = '1.0';
 
@@ -75,6 +77,11 @@ my $pie_percentage_limit = 2;
 
 my $t0 = Benchmark->new;
 
+# Get the decimal separator
+my $n = 5/2;
+my $num_sep = ',';
+$num_sep = ' ' if ($n =~ /,/);
+
 # get the command line parameters
 my $result = GetOptions (
        "l|logfile=s"   => \$logfile,
@@ -560,7 +567,7 @@ sub comma_numbers
 
         my $text = reverse $_[0];
 
-        $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
+        $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1$num_sep/g;
 
         return scalar reverse $text;
 }