On Saturday 12 October 2002 2:27pm, Nicholas Clark wrote: > Basically, I'm wanting to be able to write a subroutine skip that can be > called unknowingly like this: > > { > ... # stuff > skip ("innocent parameter of some sort"); > ... # more stuff > } # X > > and have skip hang some sort of call back that fires when the scope marked > with X exits.
Depends what you mean by "innocent parameter of some sort". If you mean that you can arrange for it always to be invoked like skip (my \$dinner); then easy, you just say sub skip { $_[0] = new Callback sub { # write Callback.pm yourself :-) # do whatever needs to be done in the callback }; } If you can't arrange for skip() to be called like that, maybe you could use B::Utils and B::Generate to add in that extra first parameter yourself? Warning: I really don't know whether or not it's feasible. But even if it is, it still looks very hairy.... -- \|/GET| Dave Hinton -/SOME| Battersea, London, England /SLEEP| http://thereaction.co.uk/dah