
Hook::wrapsub lets you wrap a function, providing one or both of functions that are called just before and just after, whenever the wrapped function is called.
the wrap_subs() function enables intercepting a call to any named function; handlers may be added both before and after the call to the intercepted function.