First, for your command line switches, take a look at Getopt::Long. You can call the GetOptions function in a BEGIN{} block before loading modules with use. That will allow you to influence module loading with the command-line switches. G::L is shipped with perl, so there should be no hassle using it.

Why do I mention modules?

Your desire for overriding subroutines can easily be handled in OO Perl. You can make the ordinary case a base class, and subclass that to override. Having your data handling tucked away in modules which define the methods which apply to particular types of data allows you the flewxibility of reuse.

You could just write your subroutines to look at some state set by switches, but that strategy is brittle and doesn't scale well.

The if.pm module is very helpful for conditional module loading.

After Compline,
Zaxo


In reply to Re: defaults via Module from outside by Zaxo
in thread defaults via Module from outside by bugsbunny

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.