sub format_amount { my $amt = shift; my $cent = (split /\D/, $amt)[-1]; defined $cent and $amt =~ /\D/ ? do { $amt =~ s/($cent)$//; length $cent < 2 && ($cent .= '0'); } : ($cent = '00'); $amt =~ s/\D//g; $amt .= ".$cent"; $config{'currency'} == 0 # Dollar notation ? ($amt =~ s/(\d{1,3})(?=(?:\d{3}))/$1\,/g) : do { $amt =~ s/(\d{1,3})(?=(?:\d{3}))/$1\./g; $amt =~ s/(\.(\d{2}))$/\,$2/; }; return $amt; }