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

To do it without capturing and resubstituting, you can add a lookbehind:
s/(?<=\d)(?=(?:\d{3})+\b)/$sep/g;
This also works:
substr($n, pos($n), 0) = $sep while ($n =~ /\d(?=(?:\d{3})+\b)/g);
As does:
substr($n, -($_*3 + ($_-1)*length($sep)), 0) = $sep for (1..int((lengt +h($n)-1)/3));