In relation to this node on microlanguages, I've been working on implementing the subset features as several modules, such that they look as follows:
$data = /some data read from file, perl object/; $data = process_A( $data, @options ); $data = process_B( $data, @more_options );
In every case I've written so far, the data type object is always the first argument to these functions. The process functions are contained in their own modules, such as MyCode::ProcessA, MyCode::ProcessB, etc. These functions typically return a new data type object.

Now, in the aforementioned thread, someone suggested that objectifying this might make more sense:

$data = /some data read from file, perl object/; $data = $data->process_A( @options ); $data = $data->process_B( @more_options );
which is just as clean (if not cleaner). However, the number of 'process' functions that I might generate are not limited, and that means that every time I add a new module with a new process, I'd have to modify the data type code in addition to add this feature, which is a nuicance.

So, I'm wondering if there is a "stupid perl trick" that's sufficiently portable (between 5.005 and 5.6) such that when the process moduels are loaded, they can automagically load any appropriate functions into the data type method list, eg:

# data type object at this point has no 'process_c' method. use MyCode::ProcessC; # now it ought to.. $newdata = $data->process_c( @even_more_options );
I figure if anything, this will be something in the BEGIN block for the process modules and possibly an AUTOLOAD in the data type code, but I'm not sure what needs to be added. Any suggestions or am I asking for the impossble?

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important


In reply to Possible Stupid Perl Trick - Importing method into object class? by Masem

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.