Actually the title isn't quite accurate. I'm passing coderefs into other packages and they run fine. But any other functions called from the coderefs are called in the 'wrong' (the destination) package, not the package that the coderefs come from. Here's my example:
use webdav;
my %callback = ( get_properties => \&get_properties_callb
+ack,
get_content => \&get_content,
get_options => \&get_options,
put_content => \&put_content,
move_member => \&move_member,
copy_member => \©_member,
make_collection => \&make_collection,
delete_member => \&delete_member,
);
webdavlisten(%callback);
package webdav;
#Exports, etc etc
sub webdavlisten {
my %callback = @_;
...
&{$callback{get_content}}(data...);
The callbacks work, but when any of the callback code calls another fuction, it calls it in the webdav package. Naturally the user is going to want to add a few support routines for his callbacks. The only thing I can think of to do is to use the caller function to see where webdavlisten is being called from, but even that is inelegant because there is no compulsion to call webdavlisten from the same package that the callbacks are defined in.
I'm happy to jettison the coderef callback and go OO if neccessary, but it seemed to me that this provided the most convenient way to pass the functions.
____________________
Jeremy
I didn't believe in evil until I dated it.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.