On Mon, Jan 21, 2002 at 08:12:42PM +0000, Robin Houston wrote:
> Do you want to find the coderef of foo from _within_ a pre or post
> handler?

No, within foo (or something foo may happen to implictly call)

I'm crazy but not that crazy.

I found a solution as I stepped off the train - and then I had to run
home so I didn't forget it.  It can be as simple as:

my %wrapped;
my $foo = \&foo;
wrap *foo => pre => sub {};
$wrapped{ *foo{CODE} } = $foo;

And then later look it up as

my $sub = $wrapped{ \&{ (caller 4)[3] } };

It's not a very general case, but since I'm doing the wrapping I can
control how we get back home.

> It can certainly be done using Want-like techniques, but it'll make
> you go blind...

I spent most of my walk to the train station talking to myself trying
to figure out where foo really was, in relation to the call stack, and
then realising that what caller() exposes is only really a consensual
callstack, so I think it's a little late now...

But I now have the rw case working :)

-- 
Richard Clamp <[EMAIL PROTECTED]>

Reply via email to