main::(debug.pl:4): my @parole = qw(Salutations Hello Hey); DB<1> l 4==> my @parole = qw(Salutations Hello Hey); 5 6: print_line(@parole); 7: print “Donen”; 8 9 # Our subroutine which accepts an array, then prints 10 # the value of each element appended to “Perl World.” 11 sub print_line 12 { 13: my @parole = @_; DB<1> l 14: foreach (@parole) 15 { 16: print “$_ Perl Worldn”; 17 } 18 } DB<1> b 16 /Hey/ DB<2> c Salutations Perl World Hello Perl World main::print_line(debug.pl:16): print “$_ Perl Worldn”; DB<2> p Hey Notice that we’ve demonstrated several things here: the source listing command l, the conditional breakpoint with the criterion that $_must match /Hey/, and that $_is the default variable for the pcommand (because pjust calls print). The capability of the debugger to insert code that gets executed in the context of the program being debugged does not exist in compiled languages and is a significant example of the kind of thing that is possible in a language as well designed as Perl. The command L lists all breakpoints. 7.2.6 Taking Action: a, A An even more advanced use of the facility to execute arbitrary code in the debugger is the action capability. With the a command (syntax: aline code), you can specify code to be executed just before a line would be executed. (If a breakpoint is set for that line, the action executes first; then you get the debugger prompt.) The action can be arbitrarily complicated and, unlike this facility in debuggers for compiled languages, lets you reach into the program itself: main::(debug.pl:4): my @parole = qw(Salutations Hello Hey); DB<1> a 16 s/Hey/Greetings/ DB<2> c
Hint: This post is supported by Gama besplatan domen provider