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