in reply to Tweaking 'return'.

I can't remember what it's called, but there's a module that wraps a function call with pre and post handlers. Sounds perfect if you want to do this for a few functions.

Update: I found Hook::PrePostCall, but I think there's another one. I haven't used either.

Replies are listed 'Best First'.
Re^2: Tweaking 'return'.
by fishbot_v2 (Chaplain) on Nov 22, 2005 at 22:10 UTC
    ...but I think there's another one...

    There is Hook::LexWrap:

    use Hook::LexWrap; wrap( $_, pre => sub { print "$_ begin\n" }, post => sub { print "$_ end\n" }, ) for @subs_to_wrap;

    Updated example to be more inline with OP's requirements.

Re^2: Tweaking 'return'.
by jdporter (Paladin) on Nov 23, 2005 at 16:18 UTC
    ... I think there's another one.

    There's also Hook::WrapSub:

    use Hook::WrapSub qw( wrap_subs ); wrap_subs( sub { print "before $Hook::WrapSub::name (@_)\n" }, @subs_to_wrap, sub { print "after $Hook::WrapSub::name (@Hook::WrapSub::result)\n" +} );
    We're building the house of the future together.