Update Please disregard this posting. I finally understood the issue (see id:://713852).
caller(1) returns info about f's caller

If this is the case, I would understand why my approach failed. But then I don't understand why in my original program, caller(1) (executed from within _format_caller) delivered

main,U:\develsv\ARTS\playground\callertest.pl,16,main::f,1,,,,2,UUUUUU +UUUUU
That is, it says "the caller is main::f". This is _format_caller's caller, NOT f's caller. Actually that's why I had concluded that counting would start at 1. And indeed, from the command line:

perl -lwe 'sub a{print((caller 0)[3])};sub b{a()};sub c{b()}; c'
gives main::a (that is, caller 0 says "who I am", i.e. which function is invoking caller).
perl -lwe 'sub a{print((caller 1)[3])};sub b{a()};sub c{b()}; c'
gives main::b (that is, caller 1 says who has called me)
perl -lwe 'sub a{print((caller 2)[3])};sub b{a()};sub c{b()}; c'
gives main::c (that is, the caller of main::b), but for
perl -lwe 'sub a{print((caller 3)[3])};sub b{a()};sub c{b()}; c'
I would have expected to get information about the caller of main::c, which is the main program (not the shell), but there is none.

-- 
Ronald Fischer <ynnor@mm.st>

In reply to Re^4: caller() mystery by rovf
in thread caller() mystery by rovf

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.