作者TaipeiWind (人生太奇妙了 )
看板Perl
标题[问题] printf length
时间Sun Jan 11 18:35:45 2015
为了让印出来的资料好看一些 常会使用printf
ex: printf("x = %-10s", $x);
但是有时候$x的length大於保留的长度(10)
不知道有没有高手知道如何动态的调整printf栏位长度?
感谢 :)
--
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 220.133.134.57
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Perl/M.1420972548.A.527.html
1F:推 imce: printf("x = %-10s", substr($x,0,10)); #取前10个字罗 01/11 21:53