Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Altering subroutine parameters using Hook::LexWrap

by BrowserUk (Patriarch)
on Jan 19, 2005 at 03:49 UTC ( [id://423263]=note: print w/replies, xml ) Need Help??


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);

Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.

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

    This produces "1 2 3" for me using Hook-LexWrap-0.20. (That is, it doesn't work.)

    - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://423263]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-24 02:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found