in reply to Passing coderefs across packages and calling them in the wrong package

Instead of exporting the callbacks unconditionally, why not use EXPORT_OK? Then you would have to explicitly name then in the use declaration, but I believe it may solve your problem of calling package local subroutines from the callbacks.

I.e., instead of this:

package main; use webdav; # ... package webdav; require Exporter; @ISA = qw(Exporter); @EXPORT = qw( get_content ...); # replace this

use this:

# same as above @EXPORT_OK = qw( get_content ...); # with this

And then use this in your using code:

use webdav qw( get_content ...);

Perhaps a better solution is to explicitly prefix your coderefs with the package name they live in.

dmm

If you GIVE a man a fish you feed him for a day
But,
TEACH him to fish and you feed him for a lifetime

Replies are listed 'Best First'.
Re: Re: Passing coderefs across packages and calling them in the wrong package
by jepri (Parson) on Feb 23, 2002 at 08:27 UTC
    I wasn't exporting the functions, since I was expecting the user to create them in main (or whatever package he is in). However that is an interesting idea. I'll see what happens if I create stub functions and let the user override them...

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.