in reply to Altering subroutine parameters using Hook::LexWrap
Update: As tye points out below, I was wrong.
You have to return a reference to the modifed @_ from the pre wrapper sub, if you want that to be passed to the original sub.
use strict; use Hook::LexWrap; sub some_sub{ print "@_"; } sub before{ # inject a new arg unshift @_, 'new arg'; return \@_; } wrap some_sub, pre => \&before; some_sub(1,2,3);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Altering subroutine parameters using Hook::LexWrap (nope)
by tye (Sage) on Jan 19, 2005 at 03:51 UTC |