hi, I have a simple standalone scripts, then they have subroutines (as u may expect :")).
Now I want to do the following when the -x /path/to/ExtModule.pm switch is used the script automagicaly grab all defaults from external module, plus start using some subroutines in place of its original ones...and some such
Why I want this ?
I want to have several such scripts for doing small concentrate tasks, but want when I plug them in my framework they start to fetch defaults, options from my envoirment and addapt their behaviour to it..
One example so u can understand what I'm talking about :
temlpate parser which extract/calculate "rate" (format : field=val|field2=val2|rate=basic|..). Now say I have in my script :
sub rate { return 50 if $_[0] eq 'basic'; return 150 if $_[0] eq 'bronze'; }
then when this -x switch is used (or by some other means), rate() is overloaded with a more complex evaluation in external module/s.
Now I know how I can do this i.e. in the module create main::rate() sub, modify variables in the same way $main::Var.. but is this the right way to do it !!
May be there is CPAN solution :")
So how do u do such things... what changes u do to your frameworks.... do u do such things at all :")
Part of the reason for this is 'cause I want to give some of these scripts for others to use them, but I dont want them to overcome them with all of the rest of the code that uses them...i.e. make their life easier, but still retain the abillity to add functionality easy..

tia

In reply to 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.