blakem has asked for the wisdom of the Perl Monks concerning the following question:
Is there anyway to get Exporter to overwrite subroutines that have already been defined? i.e. I would like the output of test.pl below to be "module subroutine" but can't get that behavior w/o the commented out line.
---- test.pl ----
#!/usr/bin/perl use My::Module qw(testsub); ### works, but seems to defeat the purpose of Exporter # *testsub = \&My::Module::testsub; print testsub(), "\n"; sub testsub { # "local" definition of subroutine return "local subroutine"; }
---- My/Module.pm ----
I've looked at the specific mod_perl related modules (Apache::StatINC, Apache::Reload, Stonehenge::Reload) but none of them seem to address this. They all seem to work fine if you use the full package (i.e. print My::Module::testsub(); works fine above) but I can't get main::testsub to see the new code w/o explicitly forcing it. Any ideas?package My::Module; BEGIN { use Exporter (); @ISA = qw(Exporter); @EXPORT_OK = qw(testsub); } sub testsub { # new definition for subroutine return "module subroutine"; } 1;
-Blake
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 1: Redefining Exported Subroutines (esp. in mod_perl/mason)
by tilly (Archbishop) on Jun 19, 2001 at 02:16 UTC | |
by blakem (Monsignor) on Jun 19, 2001 at 03:14 UTC | |
|
Re: Redefining Exported Subroutines (esp. in mod_perl/mason)
by dimmesdale (Friar) on Jun 19, 2001 at 02:03 UTC | |
|
Re: Redefining Exported Subroutines (esp. in mod_perl/mason)
by blakem (Monsignor) on Jun 19, 2001 at 10:36 UTC | |
|
Re: Redefining Exported Subroutines (esp. in mod_perl/mason)
by John M. Dlugosz (Monsignor) on Jun 19, 2001 at 02:17 UTC | |
|
Re: Redefining Exported Subroutines (esp. in mod_perl/mason)
by John M. Dlugosz (Monsignor) on Jun 19, 2001 at 02:21 UTC | |
by tilly (Archbishop) on Jun 19, 2001 at 02:40 UTC | |
by blakem (Monsignor) on Jun 19, 2001 at 03:18 UTC |