in reply to Re^2: XML Simple
in thread XML Simple
use Number::Format; my $x = new Number::Format(-thousands_sep => ' '); my $number = 1234567890; print $x->format_number($number);
$ perl example.pl 1 234 567 890
You will need to install Number::Format from CPAN (see other answer)
You can also try this, but it does not take into account numbers with comma's:
my $number = 1234567890; print format_number($number); sub format_number{ my($x) = @_; $x = reverse $x; $x =~ s/(\d{3})/$1 /g; $x = reverse $x; return $x; }
This prints:
1 234 567 890
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: XML Simple
by Arenas (Novice) on Jun 01, 2015 at 09:16 UTC |