Dear Brothers and Sisters,

Most of you probably know the AUTOLOAD mechanism, where we can handle subroutines that are not explicitly defined. I want something similar for entire packages. Let me explain in a little more detail what I want to achieve and why:

I want to build something that subclasses each and every class that Wx defines. I could of course create many packages by hand and make them subclasses of the specific Wx:: subclass. However, apart from it being a time-intensive job, each subclass I create would do almost the same (I don't like to write the same code multiple times), and apart from that, if there's a new version of Wx that has a new class that I don't handle yet, I have to release a new version.

Therefore I want to ask you if you see a possibility to let me create one package (Foo) in such a way, that if I call Foo::Bar->new() (where Foo::Bar isn't defined explicitly), it defines Foo::Bar on the fly and let me do the magic that I want with it.

Any suggestion is appreciated, even if it doesn't fully do what I want...


Jouke Visser
Using Perl to enable the disabled: pVoice

In reply to Creating packages on the fly by Jouke

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.