Loginskip to content

October 28th, 2006

Examine references to hashes instead of the hashes

4 ‘in’ 5 ‘=’ 6 7 ’split’ ‘+’ 8 ‘do’ 9 ‘%’ 10 11 ‘again’ ‘?’ You can even use this feature to change the values of variables in a program you are debugging, which can be a legitimate strategy for seeing how your program behaves under different circumstances. If the way your program constructs the value of some internal variable is complex and it would require numerous changes in the input to have it form the variable differently, then a good way of playing “What if?” is to stop the program at the right place in the debugger and change the value by hand. How would we stop it? Let’s see 7.2.5 Breakpointing: c, b, L An important feature of a debugger is the ability to allow your program to continue executing until some condition is met. The most common such condition is the arrival of the debugger at a particular line in your source. You can tell the Perl debugger to run until a particular line number with the c (for continue) command: main::(debug.pl:4): my @parole = qw(Salutations Hello Hey); DB<1> c 16 main::print_line(debug.pl:16): print “$_ Perl Worldn”; DB<2> What the debugger actually did was set a one-time breakpoint at line 16 and then executed your code until it got there. If it had hit another breakpoint earlier, it would have stopped there first. So what’s a breakpoint? It’s a marker set by you immediately before a line of code, invisible to anyone but the perl debugger, which causes it to halt when it gets there and return control to you with a debugger prompt. If you have a breakpoint set at a line of code that gets printed out with one of the source examination commands listed earlier, you’ll see a bnext to it. It’s analogous to putting a horse pill in the trail of bread crumbs the mouse follows so the mouse gets indigestion and stops to take a breather (we really have to give up this metaphor soon). You set a breakpoint with the b command; the most useful forms are blineor b subroutine to set a breakpoint either at a given line number or immediately upon entering a subroutine. To run until the next breakpoint, type c. To delete a breakpoint, use d line to delete the breakpoint at line number lineor D to delete all breakpoints. In certain situations you won’t want to break the next time you hit a particular breakpoint, but only when some condition is true, like every hundredth time through a loop. You can add a third argument to b specifying a condition that must be true before the debugger will stop at the breakpoint. For example,

Note: If you are looking for good and affordable webspace to host and run your servlet application check Virtualwebstudio servlet hosting services

Comments are closed.