<P>Another brief debugger, slightly more useful, could be created
with only the line:</P>
<PRE>
sub DB::DB {print ++$i; scalar <STDIN>}</PRE>
<P>This debugger would print the sequential number of encountered
statement, and would wait for you to hit a newline before continuing.</P>
<P>The following debugger is quite functional:</P>
<PRE>
{
package DB;
sub DB {}
sub sub {print ++$i, " $sub\n"; &$sub}
}</PRE>
<P>It prints the sequential number of subroutine call and the name of the
called subroutine. Note that <CODE>&DB::sub</CODE> should be compiled into the
package <CODE>DB</CODE>.</P>
<P>At the start, the debugger reads your rc file (<EM>./.perldb</EM> or
<EM>~/.perldb</EM> under Unix), which can set important options. This file may
define a subroutine <CODE>&afterinit</CODE> to be executed after the debugger is
initialized.</P>
<P>After the rc file is read, the debugger reads the PERLDB_OPTS
environment variable and parses this as the remainder of a <CODE>O ...</CODE>
line as one might enter at the debugger prompt.</P>
<P>The debugger also maintains magical internal variables, such as
<CODE>@DB::dbline</CODE>, <CODE>%DB::dbline</CODE>, which are aliases for
<CODE>@{"::_<current_file"}</CODE> <CODE>%{"::_<current_file"}</CODE>. Here <CODE>current_file</CODE>
is the currently selected file, either explicitly chosen with the
debugger's <CODE>f</CODE> command, or implicitly by flow of execution.</P>
<P>Some functions are provided to simplify customization. See
<A HREF="../../lib/Pod/perldebug.html#options">Options in the perldebug manpage</A> for description of options parsed by
<CODE>DB::parse_options(string)</CODE>. The function <CODE>DB::dump_trace(skip[,
count])</CODE> skips the specified number of frames and returns a list
containing information about the calling frames (all of them, if
<CODE>count</CODE> is missing). Each entry is reference to a a hash with
keys <CODE>context</CODE> (either <CODE>.</CODE>, <CODE>$</CODE>, or <CODE>@</CODE>), <A HREF="../../lib/Pod/perlfunc.html#item_sub"><CODE>sub</CODE></A> (subroutine
name, or info about <A HREF="../../lib/Pod/perlfunc.html#item_eval"><CODE>eval</CODE></A>), <CODE>args</CODE> (<A HREF="../../lib/Pod/perlfunc.html#item_undef"><CODE>undef</CODE></A> or a reference to
an array), <CODE>file</CODE>, and <CODE>line</CODE>.</P>
<P>The function <CODE>DB::print_trace(FH, skip[, count[, short]])</CODE> prints
formatted info about caller frames. The last two functions may be
convenient as arguments to <CODE><</CODE>, <CODE><<</CODE> commands.</P>
<P>Note that any variables and functions that are not documented in
this manpages (or in <A HREF="../../lib/Pod/perldebug.html">the perldebug manpage</A>) are considered for internal
use only, and as such are subject to change without notice.</P>