Well, if you are writing a module and you use h2xs -X -n amodulename you get several files, one of which is a test file (in the /t folder). Consider the following (fake) module Conquest::MegaGoogle:
type conquest-megagoogle.t # Before `make install' is performed this script should be runnable wi +th # `make test'. After `make install' it should work as `perl Conquest-M +egaGoogle.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More tests => 1; BEGIN { use_ok('Conquest::MegaGoogle') }; ######################### # Insert your test code below, the Test::More module is use()ed here s +o read # its man page ( perldoc Test::More ) for help writing this test scrip +t.
So the idea is to have a test script that uses the Test module. (perldoc Test will clarify things a bit)

I mention this in the framework of creating a module because you may consider trying to place a lot of those smaller scripts in an actual module. This will make your maintenance a lot easier. After all of the functionality is neatly tucked away you can use GetOpt::Long or something to manage command line parameters.

Scripts normally are:

  • easier to lose across implementations
  • confusing due to lots of duplicated parameters (e.g. -i means something different in prog2 than in prog1)
  • redundant. Lots of them duplicate code unnecessarily (because objects have to be reloaded every prog)

    Celebrate Intellectual Diversity


    In reply to Re: Setting up tests for cat-type filter programs by InfiniteSilence
    in thread Setting up tests for cat-type filter programs by dmorgo

    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.