leocharre has asked for the wisdom of the Perl Monks concerning the following question:
I have a CGI::Application::Plugin that requires MyCgiApp to use another plugin.
Let's say CGI::Application::Plugin::Scotch makes use of CGI::Application::Plugin::Session.
How do I make it so MyCgiApp does not need to 'use CGI::Application::Plugin::Session;' ?
That is..
package MyCgiApp; use base 'CGI::Application'; use CGI::Application::Plugin::Scotch; # at this point, MyCgiApp should behave as if # CGI::Application::Plugin::Session was imported into the # package.
I can get similar behavior by importing CGI::Application::Plugin::Session into CGI::Application::Plugin::Scotch, and then exporting the methods I want out to the cgiapp.
But this seems messy. The only 'clean' solution seems to be..package CGI::Application::Plugin::Scotch; use CGI::Application::Plugin::Session; use Exporter ... @EXPORT = qw/scotch session/;
package MyCgiApp; use base 'CGI::Application'; use CGI::Application::Plugin::Scotch; use CGI::Application::Plugin::Session;
Should I stick with that (seems clunky)- or is there some other way to get package x to import package y if you use package z?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: get package x to import package y if you use package z
by tilly (Archbishop) on Feb 18, 2009 at 17:59 UTC | |
|
Re: get package x to import package y if you use package z
by JavaFan (Canon) on Feb 18, 2009 at 16:59 UTC |