I'm new to object-oriented programming in Perl; I've used OO modules, of course, but for my own code I've never had to do anything relying on inheritance or anything like that.

I'm about to convert a very large procedural program to Moose, but even here, I'm not doing it so that I can override different methods.

This program has five main tasks in it, each one over 1000 lines long; right now, everything's just one huge file, with comment lines saying "Task #3: archive old files" or whatever to divide it up. For organizational purposes, I'd like to break this up into separate modules, so that my main package would be DoSomething and then I'd have DoSomething::Task1, DoSomething::Task2, etc. The main DoSomething module will have all the core code (setting up logging, reading config, etc.), and then would just call the different tasks as necessary. The end user would just write a small script invoking this, and wouldn't have to know that there are all these different submodules.

Is this the right way to set this up? How would the DoSomething module call routines in the submodules? Is there some other way I should be accomplishing this? Again, I'm not doing this for inheritance or overriding purposes, I'm doing it so that I have five separate thousand-line modules instead of one five-thousand-line mess.


In reply to Newbie OO module-structure question by Anonymous Monk

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.