YES! That works for me.

There is still one wafer-thin problem...

When I use this in an array context, I am getting the function name (and possibly other further parameters) one level above what the package, file, and line number are. I can code around this, but I also wonder if this is a bug or not. Here is a run using Perl 5.18.1:

./bin/trepan.pl example/gcd.pl 3 5
-- main::(example/gcd.pl:18)
die sprintf "Need two integer arguments, got %d", scalar(@ARGV) unless
    @ARGV == 2;
$DB::D[0] = 0
(trepanpl): @ caller
$DB::D1 =
@{[
    [0]  "main",
    1  "example/gcd.pl",
    2  18,
    3  "DB::DB", <---- WRONG!
    4  "",
    5  1,
    6  undef,
    7  undef,
    8  2018,
    9  "UUUUUUUUUUUUUUUU",
    10 undef
]}
(trepanpl): @ caller 1
$DB::D2 =
@{<undef>}
(trepanpl): c gcd
-> main::(example/gcd.pl:8)
{
    my ($a, $b) = @_;
trepanpl: s   # there is a "feature" here in my program where I need to step one more
x1 main::(example/gcd.pl:9)
    my ($a, $b) = @_;
(trepanpl): @ caller
$DB::D2 =
@{[
    [0]  "main",
    1  "example/gcd.pl",
    2  9,
    3  "DB::DB",  <--- still wrong
    4  "",
    5  1,
    6  undef,
    7  undef,
    8  1762,
    9  "UUUUUUUUUUUUUUUU",
    10 undef
]}
(trepanpl): @ caller 1
$DB::D3 =
@{[
    [0]  "main",
    1  "example/gcd.pl",
    2  21,
    3  "main::gcd",
    4  1,
    5  1,
    6  undef,
    7  undef,
    8  2018,
    9  "UUUUUUUUUUUUUUUU",
    10 undef
]}
(trepanpl): @ caller 2
$DB::D4 =
@{<undef>}
(trepanpl): q
Really quit? (N/y) y
trepan.pl: That's all, folks...

If you want to try the code yourself, see the github Devel::Trepan repo with a commit after 0babe47e08831a9d5b1099a9971fc2677f604331


In reply to Re^4: How/can one do save/restore CORE::caller inside an eval? by rockyb
in thread How/can one do save/restore CORE::caller inside an eval? by rockyb

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.