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.

package CGI::Application::Plugin::Scotch; use CGI::Application::Plugin::Session; use Exporter ... @EXPORT = qw/scotch session/;
But this seems messy. The only 'clean' solution seems to be..
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?


In reply to get package x to import package y if you use package z by leocharre

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.