Some important lesson you can absorb before starting is

'Plan to write your library twice, you will anyway'

which means, because you aren't really sure what you want, or how to do it properly, your first attempt will be OK, but you'll soon wish you had done it differently. Dont worry, do it again, using the lessons AND experience you now have.

'Try to write the interface in a way you think wont need to change'

Hard to do, especially if this is your first attempt. Generalise what you are trying to do. Dont write a 'calculate_fuel_tax()' function or method. Perhaps an 'apply_tax(tax_type)' method is more general, with the _implementation_ doing the gritty work for each tax type.

'Write test cases for EVERYTHING in your library'

In short, if you decide at some point to replace the guts of a method (or entire library), a regression test suite gives you a lot of confidence your dependent code and libraries will still work. Its like replacing your car engine from petrol to electric - as long as all the controls still work the same way, you can drive it exactly the same way.
Use the excellent Test::More and ExtUtils::MakeMaker modules - learn to use them very well, it is well worth the effort - study existing CPAN modules for how they use them

A technical suggestion

'Use hashes as your parameters to methods/functions'

The code becomes self documenting, and more mnemonic. Which is easier to understand and remember

my $result = apply_tax(type => 'fuel', state => 'CA', period_start => '01/02/2004', period_end => '12/02/2004');
or
my $result = apply_tax('fuel', 'CA', '01/02/2004', '12/02/2004');

+++++++++++++++++
#!/usr/bin/perl
use warnings;use strict;use brain;


In reply to Re: Perl Templates by leriksen
in thread Perl Templates by ellem

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.