I made a valiant attempt to properly modularize this for you and explain how to continue, but my time was cut short. If nobody else does so by the time I'm awake tomorrow, I'll write you a full-blown example, using your code (with necessary modifications).

Essentially, the easiest way is to make it a real module:

> cpan install Module::Starter > module-starter --author="Your Name" --email=your_email@example.com - +-license=perl --eumm --module=Dreamcar

...then:

> cd Dreamcar > mkdir lib/Dreamcar

...then put your Dreamcar package info into lib/Dreamcar.pm, and underneath lib/Dreamcar/, put the Scuderia package in Scuderia.pm and the Da_corsa package in Da_corsa.pm. You'll need to reference them as Dreamcar::Scuderia and Dreamcar::Da_corsa.

After that, review t/00-load.t, and copy it to t/01_cars.t, and put your test cases in there.

Once done and working, you can simply run perl Makefile.PL (once), and thereafter a make test will test everything without reinstall or referencing any other locations. This makes it portable, and these are called unit tests.

Again, I'm sorry I can't elaborate right now, but it gives you something to think about until I can write up a full-blown example tomorrow (hopefully another Monk will have the time to put this together by then).


In reply to Re: PM module question/improvements by stevieb
in thread PM module question/improvements by perlynewby

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.