我的目标是调试(逐步)下面的sample.pl脚本.
问题:我没有得到变量的实际值($top_number,$x,$total).
我的问题:如何查看($top_number,$total)的实数整数值
从跟踪输出?
需要更改perl -d:Trace以获取数字,而不是:$top_number,$total?
跟踪输出示例:
[root@linux /tmp]# perl -d:Trace ./sample.pl
>> ./sampl.pl:9: $top_number = 100;
>> ./sampl.pl:10: $x = 1;
>> ./sampl.pl:11: $total = 0;
>> ./sampl.pl:12: while ( $x <= $top_number ) {
>> ./sampl.pl:13: $total = $total + $x; # short form: $total += $x;
>> ./sampl.pl:14: $x += 1; # do you follow this short form?
>> ./sampl.pl:13: $total = $total + $x; # short form: $total += $x;
>> ./sampl.pl:14: $x += 1; # do you follow this short form?
>> ./sampl.pl:13: $total = $total + $x; # short form: $total += $x;
>> ./sampl.pl:14: $x += 1; # do you follow this short form?
.
.
[root@linux /tmp]#more sample.pl script
#!/usr/bin/perl
$top_number = 100;
$x = 1;
$total = 0;
while ( $x <= $top_number ) {
$total = $total + $x; # short form: $total += $x;
$x += 1; # do you follow this short form?
}
print "The total from 1 to $top_number is $total\n";