perl中变量的格式化可以使用sprintf函数
$var1="bssdata";
$var2="bsswork.cust_hist_p";
$header=sprintf("%24s","header") . "|\n";
$var1=sprintf("%24s","$var1") . "|\n";
$var2=sprintf("%24s","$var2") . "|\n";
print "$header$var1$var2";
^D
header|
bssdata|
bsswork.cust_hist_p|
靠左
$var1="bssdata";
$var2="bsswork.cust_hist_p";
$header=sprintf("%-24s","header") . "|\n";
$var1=sprintf("%-24s","$var1") . "|\n";
$var2=sprintf("%-24s","$var2") . "|\n";
print "$header$var1$var2";
^D
header |
bssdata |
bsswork.cust_hist_p |
阅读(692) | 评论(0) | 转发(0) |