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
    hello @FBRM Many Thanks for your reply! The better expression is "Mask" I have find also this: http://bip.weizmann.ac.il/course/prog2/pm/Number_Format.html "From germany"
    #!/usr/bin/perl $number = '12586' use Number::Format qw(:subs :vars); $THOUSANDS_SEP = '.'; $DECIMAL_POINT = ','; $INT_CURR_SYMBOL = 'DEM'; my $formatted = format_number($number); format_picture($number, '## ### ### ###')
    Gestion: How can i run this little stuff?

    Greats,

    @r