in reply to How do I print a large integer with thousands separators?

sub puntato { my $n=reverse($_[0]); my $x=''; while(length($n)>3) { $x=$x.substr($n,0,3).'.'; $n=substr($n,3); } $x=reverse($x.$n); return($x); }

Replies are listed 'Best First'.
Re: Answer: How do I print a large integer with thousands separators?
by borisz (Canon) on Jan 09, 2004 at 16:25 UTC
    How about this?
    sub puntato{ my $z=reverse $_[0];$z=~s/(\d{3})(?=\d)/$1\./g;scalar(rev +erse($z))}
    Boris