Gurus,
It's said that perl debugger support to set a breakpoint by a code reference. but I really never succeed to set such kind of breakpoint.
b $var Set breakpoint at first line of subroutine referenced by $var.I'd like to give an example including codes and my debug process.
#!/usr/bin/env perl use 5.016; my $mysubref = sub { say "This is code Ref 0"; say "This is code Ref 1"; say "This is code Ref 2"; }; testMethod(); sub testMethod { say "in testMethod"; &{$mysubref}; } say "end the program";
The debug process is,
H:\store\workspace\myTestCodes>perl -d .\test6.pl Loading DB routines from perl5db.pl version 1.37 Editor support available. Enter h or 'h h' for help, or 'perldoc perldebug' for more help. main::(.\test6.pl:8): }; DB<1> c 10 main::(.\test6.pl:10): testMethod(); DB<2> b $mysubref DB<3> L b .\test6.pl: 10: testMethod(); break if ($mysubref) DB<4> c in testMethod This is code Ref 0 This is code Ref 1 This is code Ref 2 end the program Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info. DB<4>
'b $mysubref' seems not to work.
Please tell me what's wrong here. How can I set a breakpoint by a code reference?
Thanks in advance.
In reply to how to set a breakpoint by a code reference by Matq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |