in reply to Re: Make debugger break on source lines matching a pattern
in thread Make debugger break on source lines matching a pattern

Howdy Rolf,

I had the same thought about overriding "print" but that's one of the core ops that it won't work for, since there's no prototype letting the parser treat it like a sub. (And there's no CORE::print to break on either).

Possible to completely hack a solution along the lines of perl -pi.bak -e "s/\bprint\b/$DB_single=1;\nprint/" or do something exceedingly clever with B::Util- though simply adding a few breakpoints by hand will do all I need to do with far less room for making things worse!

ps. thanks for the link to obsidianrook, I always enjoy those presentations!

  • Comment on Re^2: Make debugger break on source lines matching a pattern

Replies are listed 'Best First'.
Re^3: Make debugger break on source lines matching a pattern
by LanX (Saint) on Jan 11, 2014 at 21:07 UTC
    > no prototype letting the parser treat it like a sub.

    true, most probably cause of it's magic behavior as handle-method. Though looking into IO::Handle might help.

    Anyway, I don't know what your prints are supposed to do, but before relying on source-filtering I'd rather rename them like dbout or out or say.

    The following code breaks on each output, simply uncommenting use feature disables this behavior.

    #use feature 'say'; sub say { print @_,"\n"; no warnings 'once'; $DB::single=1; } say $x++; say $x++; say $x++; say $x++; say $x++;

    > ps. thanks for the link to obsidianrook, I always enjoy those presentations!

    Well, better thank doom directly! =)

    Cheers Rolf

    ( addicted to the Perl Programming Language)