In doing some hacking[0] with Hook::LexWrap and caller, doing dodgy
things to try and find the true coderef of the code that's calling me,
so I can do even more dodgy things to its pad, and I've hit a
stumbling block.

Hook::LexWrap turns something like this:

sub foo {
    print "Hi kids, I'm foo\n";
}

wrap foo => pre  => sub { print "I'm wrapping foo\n" },
            post => sub { print "done wrapping foo\n" }

Into something a bit like this:

sub foo {
    print "Hi kids, I'm foo\n";
}

my $original = \&foo;
*foo = sub {
    print "I'm wrapping foo\n";
    &$original;
    print "end of wrapping\n";
};

foo();


No my problem comes from finding the coderef that was the original
foo, so I can PadWalk it.  I was previously using

   my $sub = \&{ (caller 1)[3];

but in mixing in a lexical wrapper that resolves to the outer wrapper,
whose pad isn't the one I care about.

Now my question - does anyone know of a good way to get the true Cv in
this case - or shall I just steal some more code and implement my own
calllevel-to-cv implementation?


[0] Though I've told people what it is for already I'm hoping to
reveal all properly on Thursday with a working implementation.

-- 
Richard Clamp <[EMAIL PROTECTED]>

Reply via email to