Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by Yary (Pilgrim)
on Jan 11, 2014 at 20:35 UTC ( [id://1070289]=note: print w/replies, xml ) Need Help??


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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1070289]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-24 02:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found