Reputation: 7938
While using perl debugger, is there any way to step out of the current loop?
For example:
line 1
for($i=1;$i<100000:$i++)
{
line2
}
line3
I want the debugger to step out of this for loop and stop at line3
Upvotes: 3
Views: 3742
Reputation: 13189
You can just set the loop termination condition:
$i=100000
Elaborate? Just set the variable to the exit condition like so:
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,
Upvotes: 2
Reputation: 2345
There is no step out.
You can either setup a break point on "line 3" and continue "c" to next breakpoint, or explicitly state c <line #>
to stop at a particular line.
Upvotes: 0
Reputation: 385655
c 5
Demonstration:
>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,
Upvotes: 7