Melly has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monkees
I have a perl program that I'm rewriting to accommodate the growing list of requirements.
One thing I want/need to do is to have 3 different packages containing subroutines with, potentially, the same names (not a problem).
I will have a global package, GP, a local package, LP, and a file package, FP, so that people can call GP::format_date, or LP::format_date, etc.
My problem is the FP package. GP and LP are loaded at run-time, but FP needs to have its routines reloaded during the program's duration (basically, everytime I switch to a new file, I want to initialise and repopulate FP with routines defined in filename.lib
Any suggestions?
Another nice feature (although not essential) would be to allow the user NOT to specify the package name, and have the program default to FP::routine if it exists, then LP::routine if it exists, before finally defaulting to GP::routine (and returning an error if the routine doesn't exist in any package). I would also need the user to be able to over-ride this by explicitly specifying the package...
As I said, the last requirement is not essential - I can always require the users to specify the package, but it would be nice.
Tom Melly, pm (at) cursingmaggot (stop) co (stop) ukmap{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Redefine package subroutines
by tobyink (Canon) on Dec 19, 2012 at 11:45 UTC | |
by tobyink (Canon) on Dec 19, 2012 at 12:15 UTC | |
Re: Redefine package subroutines
by space_monk (Chaplain) on Dec 19, 2012 at 11:24 UTC | |
Re: Redefine package subroutines
by Melly (Chaplain) on Dec 19, 2012 at 14:05 UTC | |
by tobyink (Canon) on Dec 19, 2012 at 14:33 UTC | |
by Melly (Chaplain) on Dec 19, 2012 at 14:51 UTC | |
Re: Redefine package subroutines
by Melly (Chaplain) on Dec 21, 2012 at 06:22 UTC |