From: Darold Date: Sat, 9 Jun 2012 12:19:18 +0000 (+0200) Subject: Set thousand separator and decimal separator locale dependant X-Git-Tag: v3.2~227 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d3f688e7082b0eb47feb4e4379b00420ac6e30a5;p=pgbadger Set thousand separator and decimal separator locale dependant --- diff --git a/pgbadger b/pgbadger index 3c2ad9a..e319079 100755 --- 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; }