Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Perl debugging initialization: did I just reinvent the wheel?

by mpersico (Monk)
on Dec 01, 2016 at 19:53 UTC ( [id://1177077]=perlquestion: print w/replies, xml ) Need Help??

mpersico has asked for the wisdom of the Perl Monks concerning the following question:

I have worked out a system that allows me to maintain breakpoints in the Perl debugger from session to session and load them up next time I run the debugger:

First, I create a ~/.perldb file that contains:

## -*- cperl -*- sub afterinit { use Cwd; my $dbg = getcwd(). "/.perldb"; print "$dbg...\n"; if ( -e $dbg ) { no strict; do $dbg; } }

Then I create a local .perldb file in the current working directory where I run  perl -d:

## -*- cperl -*- push @DB::typeahead, 'f Some.pm', 'b 75', 'f bin/mymainscript', 'b 180', 'b 192', 'L';

So, my questions are:

1) Is this technique widely enough known that I would look like an idiot for blogging about it?

2) Is the usage of @DB::typeahead unsafe in that it's a direct tap into the DB module that may be changed and, therefore, should not be promoted?

Thank you.

Replies are listed 'Best First'.
Re: Perl debugging initialization: did I just reinvent the wheel?
by LanX (Saint) on Dec 01, 2016 at 21:02 UTC
    TIMTOWTDI.

    The book Pro Perl Debugging lists many unknown features, like the two you are combining.

    But thanks for posting!

    It doesn't really matter if you reinvented the wheel. :)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Re: Perl debugging initialization: did I just reinvent the wheel?
by thomas895 (Deacon) on Dec 01, 2016 at 19:58 UTC
      Yep - using an ennvar was going to be my next enhancement. If I blog this, I'll credit your prior post. Great minds think alike? <grin>
Re: Perl debugging initialization: did I just reinvent the wheel? (names)
by tye (Sage) on Dec 02, 2016 at 04:40 UTC

    I would avoid using the file name ".perldb" for both types of files. I'd have your ~/.perldb look for a ./.perldbinit file instead. You'll avoid some confusion, including when you try to use the Perl debugger in your home directory.

    - tye        

      ~/.perldb is the only file that -d will read - that's a perl debugger standard. I don't think I can change that.
        Reread what tye suggested: in ~/.perldb, check whether .perldbinit exists (see? No tilde!) and load it if so.

        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re: Perl debugging initialization: did I just reinvent the wheel?
by Laurent_R (Canon) on Dec 01, 2016 at 22:54 UTC
    This is apparently not completely new, but I am pretty sure that most Perl debugger users don't know about these possibilities. I have personally played a few times with the .perldb file, but never thought about using it for the purpose you illustrate. So I think it is certainly worth posting blogs about that, I am fairly sure it will be useful for some people.
Re: Perl debugging initialization: did I just reinvent the wheel?
by mpersico (Monk) on Dec 05, 2016 at 14:01 UTC
    Thank you all for your expertise and encouragement. Here's the final product.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1177077]
Approved by stevieb
Front-paged by LanX
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-24 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found