I was wondering (yes, i know i should stop).
Using perl you can do pretty much anything you were supposed to do in compile time at run time intead, right?
How's about dynamically creating namespaces?

I need an object to inherit different classes, at different times.

The object has some data, which can be passed to a 'reblesser' function, which dynamically selects where the object can go now, and if it's allowed there, and if there are several such methods which one, based on info within the object.

I thought of something with eval, or perhaps modifying %::, but i don't know how this really worked.

Another idea is using AUTOLOADER to trancend the object on demand when it needs, calling rebless when a method isn't found.
This will REALLY hurt method call times, which are slow to start with.

Which of the two methods is preferable? Do they work? How do i get around perl caching methods found in @ISA?

i haven't found much documentation, and experimenting seems to always go wrong for me, so i was hoping someone's tried this before...

-nuffin
zz zZ Z Z #!perl

In reply to Dynamicly controlling @ISA and namespaces by nothingmuch

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.