楼主:
qimog (qimog)
2014-06-16 22:07:48请问板上有无高手能够替小弟解惑,为何以printf设定变量时,该变量会多出"1"字符。
以下为实例
for (0..$Nofile-1)
{
$head=printf ("%04s_%s", $_+1, $Tar_file{$EinO[$_]});
print "$head\n";
}
得到结果为
0001_BHandHLYP.W4t.R1-4.out1
0002_BHandHLYP.W4t.R1-1.out1
0003_BHandHLYP.W4t.L3-2.out1
0004_BHandHLYP.W4t.L1-1.out1
然以
for (0..$Nofile-1)
{
printf ("%04s_%s\n", $_+1, $Tar_file{$EinO[$_]});
}
则得到
0001_BHandHLYP.W4t.R1-4.out
0002_BHandHLYP.W4t.R1-1.out
0003_BHandHLYP.W4t.L3-2.out
0004_BHandHLYP.W4t.L1-1.out
请问,为什么存入变量会在变量字串末尾多个"1"?
由于小弟一定要将之设定为变量,之后用作于排序和重新命名用。
所以希望了解这个问题的高手们,可以告诉我为什么会多个1,及如何解决呢?