Currently I'm working on a project using
POE which may possibly use other event loops (
Tk,
Gtk, etc). Due to the way POE works, any other event loops that it supports need to be loaded prior to POE itself. And due to the way my program works (gui type defined by a config file, and some cross platform issues), I don't know which one I will be using until runtime. Also, it is likely that the modules that aren't being used won't even be installed, although I don't think that should make any difference if this is done right.
I came across
this node, which had a very similiar problem, but I'm not sure exactly how that will work when I need to call a dependant module (POE) after the requires (as they aren't BEGIN blocks.) Here's what I have currently:
if( lc($config->outputs('gui')) eq 'tk' )
{
require Tk;
import Tk;
} elsif( lc($config->outputs('gui')) eq 'gtk' )
{
require Gtk;
import Gtk;
}
require POE;
import POE;
Note that I have more code prior to this that loads the $config object and so on, and after the POE module is loaded, I have to instantiate the Components I will be using. I won't actually be using Tk or whatever until inside the called Component, I'll just be posting an event to tell it what kind of GUI it will need to use. I'll just be initializing the main object and starting POE. I haven't done all that code yet, as it depends on what I do here a bit. But if you need more detail let me know. Also, I'm not sure if I need all the imports here, will it be better to just to that inside the Component itself?
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.