in reply to regexp for adding commas to a number

Out of Andrew Johnson's Elements of Perl Programming:
s/(\d{1,3}) (?= (?:\d\d\d)+ (?!\d) ) /$1,/gx;