I have several scripts which it would seem wise to turn into modules. Unfortunately, even though I have been using Perl for a long time, OO concepts still tend to feel unfamiliar to me.

I could certainly just follow perootut and perlobj, but I understand that learning Moo or something similar would make it much easier in the end, by delegating a lot of boilerplate code to such a constructor module. If only I could understand it's basics, and know where to look for simple examples...

Basically, what I do is read a file into one or more hashes, manipulate the data and write the file back.

My current interest is mainly in files like edit lists (like Avid ALE files) and subtitles of various formats (including binary formats, for which there is nothing in CPAN currently). Doing the whole thing in a simple Perl script is pretty straightforward, but I'm sick of copy/pasting chunks of code from previous scripts, and would like to learn doing it the "right way" with various modules for the various formats.

What do the wise monks think? Where can I find examples to get me started? Or am I overengineering this, and would a plain module without /Mo.*/ or /Class::.*/ be much simpler?


In reply to tutorials / examples to start using Moo (or Class::Tiny, or...?) by rduke15

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.