I've to find out, how I can read all lexical variables (declared with "my") in a block of the callerstack. I've found out, that Carp::Heavy uses some of the "magic" things in package DB like the following, to access to the given parameters:
use strict; use CGI; my $c = new CGI; $c->param('test', 'this_is_my_text'); sub one { my $this_i_want_to_access = 'no_way'; return two($c) } sub two { my $i = 0; for(1..4) { resolve_caller($_) } } sub resolve_caller { my $i = shift; # Ups! Inline usage of a package. Not my style, but there is no ot +her way for do some magic. package DB; my %call_info; @call_info{qw(pack file line sub has_args wantarray evaltext is_re +quire)} = caller($i); return unless (defined $call_info{pack}); if ($call_info{has_args}) { # This is only filled, when you call "caller($i)" IN the packa +ge DB!!! Otherwise it's empty. It's magic? my @args = @DB::args; print "Args: @args"; foreach my $c (@args) { if(ref($c)) { print " > parameter test = " . $c->param('test'); } } print "\n"; return; } return; } print one(1);
Have a look at the two comments. There is some magic in this code. I can use it, but I don't understand. This prints out:
Args: CGI=HASH(0x8148d48) > parameter test = this_is_my_text Args: 1
So at this way, I can access to lexical variables given into subroutines in callerstack. But I want to look around in the subroutines and, for example, want to access to $this_i_want_to_access.

There are some special variables, that sounds good, but what magical things I've to do, to fill them? How can I find some documentation about this?

$DB::trace @DB::dbline %DB::dbline @DB::ret $DB::ret %DB::sub

In reply to Usage of the DB-module (debugger) by Tobiwan

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.