Nick Ing-Simmons wrote:
> > So, while I've misstated the situation, my question stands. How
> > practical would it be to manipulate the data on the call stack?
>
> To changed it on a call-by-call basis is a bit more tricky.
> (But as C code can see whole of perl's data structuctures - possible.)
>
> I _think_ the information caller() sees for this outer level comes
> from PL_curcop at the time of the call_method().
>
> [curcop = "current control op" or some such - it roughly corresponds
> to a "statement" in a perl script. ]
>
> So
>
>    PL_curcop->cop_file = __FILE__;
>    PL_curcop->cop_line = __LINE__;
>    count = call_method("do_something", G_SCALAR);
>
> may do what I think you want.

That got me much closer. Apparently, "cop_file" is not a member of
"cop" unless one has built with ithreads, I'm not sure what the
relationship is.  The alternative preprocessor block *does* include a
"cop_filegv".  I fooled around with it a little, but the results
weren't very interesting. Assigning "cop_line" had the desired affect
though.

    fprintf(stderr, "PL_curcop->cop_line: %d\n",
        PL_curcop->cop_line);

    PL_curcop->cop_line            = __LINE__;
    sv_setpv(PL_curcop->cop_filegv , __FILE__);

    fprintf(stderr, "PL_curcop->cop_line: %d\n",
        PL_curcop->cop_line);
    fprintf(stderr, "PL_curcop->cop_filegv: %s\n",
        SvPV_nolen(PL_curcop->cop_filegv));

    call_method("do_it", G_DISCARD);


= Output ===================================================

    PL_curcop->cop_line: 0
    PL_curcop->cop_line: 142
    PL_curcop->cop_filegv: eg.c
    doing it... at /dev/null line 142

thanks again

Reply via email to