![]() |
|
Just another Perl shrine | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
Hmm. Let me see if I understand: you want to be able
to do something like grep or map, where your code gets
passed a subref which you then call back?
If so, you don't need to worry about changing packages at the time you call it, since it will have already picked up the proper package when it was defined (and compiled) in the caller's code: In the above code, my::own_map could have molested ${ (caller)[0] . "::global" } to pass a value in to the block. I guess this might be OK (although it's clearly an abuse of caller, which AFAIK was intended for debugging), as long as it's well documented and you are careful to localize everything. Updated: removed a confusing and unneeded $_ argument on the line that calls the callback. Oops!
In reply to Re: Re: Re: Callback Design
by saucepan
|
|