Once or twice, Ive tried to add a self-debug flag to scripts, ie: a -d option that would invoke perl in debug mode, and set you up and ready. These have thus far been unsatisfactory.

Ive also tried -d on the scripts shebang line, with autorun setup. iirc this was a bit better, but I dont recall ever getting it to just run without at least a "c\n" at the prompt.

Arguably this can be done currently with a concoction of stuff starting with .perl5db.pl, but having the ability to put it all in-file would increase awareness and use (just like POD did), and engender more sophisticated stuff, like setting up a series of conditional breakpoints specific to the code, and providing some doc of how a problem was narrowed, isolated, and squashed.

strawman:


use DB (init => q{ 
                 b load Foo::DelayedLoad;
                 b Foo::bar @_>50      # catch long arglist
                 # trap bad args to setprops: $me,%props =@_
                 b Foo::setProps !(@_ % 2); 
                 # etc...
                 },
        init_bug_201 => q{ doc only, ignored so it can 
                            be preserved unaltered }
    );

or can this all be done currently ?

or can the artfullness thats required be explored here so that it can be copied by more pedestrian practishoners ( parishoners ?) such as myself ?

OK heres some code that kinda works:

#!/usr/local/bin/perl -d

use Getopt::Std;

BEGIN {
  DB::parse_options("NonStop=1"); # LineInfo=db.out AutoTrace");
    #$DB::single = 0;
    $DB::inhibit_exit = 0;
    $DB::lastcmd = 'c';   # I think this fixes the "c\n"
}


getopts('di') or die "bad args";

if ($opt_d) {
    print "hello 1\n";
    $DB::single = 1;
}

if ($opt_i) {
    print "hello 2\n";
    $DB::single = 2;
}

print "hello world\n";



perl-play$ selfdebug.pl -d

Loading DB routines from perl5db.pl version 1.23
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

             NonStop = '1'
hello 1
main::(./selfdebug.pl:20):	if ($opt_i) {
  DB<1> q
perl-play$ selfdebug.pl   

Loading DB routines from perl5db.pl version 1.23
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

             NonStop = '1'
hello world
perl-play$ 

In reply to Reflexive debug mode by kidongrok

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.