in reply to Altering subroutine parameters using Hook::LexWrap

Thanks for all the replies. It seems that I cannot do this (easily) with Hook::LexWrap, and the best way is to wrap manually or use alternatives like Hook::WrapSub (at least in cases where one does not need lexical wrappings that unwrap themselves when falling out of scope).

But this is a bug in Hook::LexWrap, right? The documentation seems to indicate that it should be possible, and there is even example code illustrating this feature (which does not seem to work)

wrap set_temp, pre => sub { splice @_, 0, 1, $_[0] * 1.8 + 32 }, post => sub { $_[-1] = ($_[0] - 32) / 1.8 };

Replies are listed 'Best First'.
Re^2: Altering subroutine parameters using Hook::LexWrap (bug?)
by tye (Sage) on Jan 19, 2005 at 05:05 UTC

    It is not simply a bug. The documentation uses splice incorrectly but that example could be fixed by modifying $_[0] instead.

    Fixing this short-coming really requires a change to the documented API. BrowserUk has already implemented that nicely. Now fix the documentation and address backward compatability and you can fix the module.

    - tye