in reply to Formatting a number

This is a FAQ. Please type perldoc -q commify and/or read the documentation online.

Replies are listed 'Best First'.
Re^2: Formatting a number
by harryf (Beadle) on Oct 16, 2006 at 13:19 UTC
    Thanks - missed that (and I guess I should have searched harder as this is a command problem: apologies). Nice regex though - finally see the point of \G ;)
    $num =~ s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g;
    Thanks.