使用perl调试器时,有什么办法可以跳出当前循环吗?Perl调试器 - 如何跳出循环
例如:
line 1
for($i=1;$i<100000:$i++)
{
line2
}
line3
我想调试器来逐步摆脱这种为循环,并在3号线停止
使用perl调试器时,有什么办法可以跳出当前循环吗?Perl调试器 - 如何跳出循环
例如:
line 1
for($i=1;$i<100000:$i++)
{
line2
}
line3
我想调试器来逐步摆脱这种为循环,并在3号线停止
c 5
示范:
>perl -d
Loading DB routines from perl5db.pl version 1.33
Editor support available.
Enter h or `h h' for help, or `perldoc perldebug' for more help.
print "line1\n";
for (1..100000) {
print "line2\n";
}
print "line3\n";
^Z
main::(-:1): print "line1\n";
DB<1> s
line1
main::(-:2): for (1..100000) {
DB<1> s
main::(-:3): print "line2\n";
DB<1> s
line2
main::(-:3): print "line2\n";
DB<1> c 5
line2
line2
line2
...
line2
line2
line2
main::(-:5): print "line3\n";
DB<2> s
line3
Debugged program terminated. Use q to quit or R to restart,
c 3
手段继续执行并停在第3行
没有步骤。 您可以在“第3行”上设置断点并将“c”设置为下一个断点,或者明确指定c <line #>
停止在特定行。
您可以只设置循环的终止条件:
$i=100000
详细点吗?只需将变量设置为退出条件,如下所示:
DB<5> $i=1
DB<6> print $i
1
DB<7> $i=100000
DB<8> print $i
100000
DB<9> c
Debugged program terminated. Use q to quit or R to restart,
可以请您详细说明一下吗? – AnonGeek
+1详细答案 –