in reply to Altering subroutine parameters using Hook::LexWrap
Use the source, Luke. The module's code isn't particularly hard to understand. It is clear that you can't change @_ (only elements of @_) in a pre-wrapper and the example with splice in the docs is clearly wrong.
You can wrap a routine yourself much more flexibly and less magicly with rather simple code:
sub some_sub { print "(@_)\n"; } my $orig= \&some_sub; *some_sub= sub { $orig->( 'newArg', @_ ); }; some_sub( "test", "ing" );
produces:
(newArg test ing)
Make sense?
- tye
|
|---|