As I mentioned, using the "package" construct within same file was a "development" step before potentially splitting it off into another file.

The objectification of the items in the packages is _desirable_, but I haven't gotten to the point of figuring out what things I want to "objectify".

It's a case of I first developed a "script" (if you can call something around 500+ lines 'a script' :-)) -- that started as "hacks" (my first GUI using Tk; hope to convert to native Win32 if/when I get things properly abstracted and objectified). So your advice to restructure using objects is desirable, though possibly premature -- I'm trying to "evolve" the program toward something more modular and clean. Starting from an example that displays a single "picture", I've been evolving/modifying the program from there.

From the large glob of "prog" I have now, I want to move to objects where it makes sense, but first I want to "conceptually" break apart "functions" by putting groups of functions into separate packages.

Perhaps unrealistically idealistic, I'd like to be able to accomplish:

...prog... use moda; use modb; ....
where instead of putting the code for "moda" and "modb" in separate files, I can include it "inline". Ideally, I'd like to use the standard "Export" type functions within the defined packages, to somehow specify the functions I want to use as interface functions.

I notice you are using the "*func=\&mypackage::func" notation to import specific names from the packages. Is there anyway to do that using the standard "Exporter" and "@Exports=" functionality? I.e. pretty much as if I literally copied a normal "package" into my file -- maintains its own namespace, but uses "Exports" to define the exported interface.

If it is not possible, at least I could use "manual" mode of "exporting" my functions from the packages into the main symbol table via the "*func=..." construct. Seemingly not as elegant as using the standard "Exporter" functions, but perhaps the best alternative.

Thanks for the suggestions...at least I can use the above temporarily until I find something better...:-)


In reply to Re^2: multiple "sub" packages in 1 file: possible? how? by perl-diddler
in thread multiple "sub" packages in 1 file: possible? how? by perl-diddler

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.