in reply to Formatting a number

Not a one-liner, but I've always used something like this:
sub commafy { my $num = reverse shift; my @threes = $num =~ /(.{1,3})/g; return scalar reverse join ',', @threes; }

Replies are listed 'Best First'.
Re^2: Formatting a number
by jwkrahn (Abbot) on Oct 16, 2006 at 19:19 UTC
    You can speed that up using unpack:
    sub commafy { return scalar reverse join ',', unpack '(a3)*', reverse shift }