in reply to Re: how to set a breakpoint by a code reference (workaround)
in thread how to set a breakpoint by a code reference

Hi LanX

I did a quick test using the workaround, but failed:(

It didn't stop at the breakpoint.

Please have a look and point out anything wrong with my test.

Thanks.

PS H:\store\workspace\myTestCodes> cat ~/.perldb $DB::alias{b} = q# s/^b\s+(\$\w+)\s*$/'"b ". DB::CvGV_name('.$1.')'/ee +; # PS H:\store\workspace\myTestCodes> cat .\test6.pl #!/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"; PS 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> n main::(.\test6.pl:10): testMethod(); DB<1> b $mysubref DB<2> L b .\test6.pl: 10: testMethod(); break if ($mysubref) DB<3> 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<3> q PS H:\store\workspace\myTestCodes> perl -v This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x +86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2012, Larry Wall Binary build 1603 [296746] provided by ActiveState http://www.ActiveSt +ate.com Built Mar 13 2013 11:29:21 Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5 source ki +t. Complete documentation for Perl, including FAQ lists, should be found +on this system using "man perl" or "perldoc perl". If you have access to + the Internet, point your browser at http://www.perl.org/, the Perl Home Pa +ge. PS H:\store\workspace\myTestCodes>

BR

Replies are listed 'Best First'.
Re^3: how to set a breakpoint by a code reference (win)
by LanX (Saint) on Nov 20, 2013 at 12:14 UTC
    I think the config isn't found cause home dir is messed up on your win system.

    Try checking with = if the alias was included.

    Try including prints in .perldb to get a feedback when sourced.

    Prepend the alias with a print to see when it fires, maybe you need to extend the regex.

    IOW localize the problem! : )

    Cheers Rolf

    ( addicted to the Perl Programming Language)

      Hi LanX

      As you have shown me the way. Let me try it myself.

      Thanks a lot.

      BR