添加数字的千位分隔符
如何把很大的数字(例如:12414223563465),添加上千位分隔符,(变成12,414,223,563,465)
写一段perl的脚本如下:
==========================
#!/usr/bin/perlwhile(<>){~s/(?<=\d)(?=(\d\d\d)+\b)/,/g;print}
==========================
保存为number.pl
运行:
perl number.pl <需要处理的文件名>
结果:
$ cat test.data
income 14234512323expense 23534523others 645647$$ perl number.pl test.data
income 14,234,512,323expense 23,534,523others 645,647

0 Comments:
发表评论
<< Home