blueflashlight has asked for the wisdom of the Perl Monks concerning the following question:
Hi, Monks ...
I recently asked for a review of my first module, and I received some very useful feedback. However, there is a question that I didn't ask that goes to the heart of my module's design, and perhaps future modules that I hope to write.
My module exports several functions; each function takes no arguments, and returns a scalar (or in one function, a three element array.) When I first started designing the module, my thought was to, instead of exporting the various functions, I would instead export a single hash, with the keys being the function names and the values being, obviously, the return of each function.
The reason I did not do that is because several of the functions may take several seconds to complete, and so the act of "use"ing the module in a script made the entire script take that longer amount of time to complete. (Note though, that if all of the functions are exported and used in the script, the script will take the same amount of time.)
Perhaps the answer to my question is "TMTOWTDI", but is there any kind of consensus to whether it is better to have a module export functions (even though the functions take no args) or variables?
thanks for all of the help I've gotten so far, and all of the help I'll be getting in the future! :-) -s-
I recently asked for a review of my first module, and I received some very useful feedback. However, there is a question that I didn't ask that goes to the heart of my module's design, and perhaps future modules that I hope to write.
My module exports several functions; each function takes no arguments, and returns a scalar (or in one function, a three element array.) When I first started designing the module, my thought was to, instead of exporting the various functions, I would instead export a single hash, with the keys being the function names and the values being, obviously, the return of each function.
The reason I did not do that is because several of the functions may take several seconds to complete, and so the act of "use"ing the module in a script made the entire script take that longer amount of time to complete. (Note though, that if all of the functions are exported and used in the script, the script will take the same amount of time.)
Perhaps the answer to my question is "TMTOWTDI", but is there any kind of consensus to whether it is better to have a module export functions (even though the functions take no args) or variables?
thanks for all of the help I've gotten so far, and all of the help I'll be getting in the future! :-) -s-
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: should a module export FUNCTIONS or VARIABLES?
by andreychek (Parson) on Jul 02, 2001 at 19:02 UTC | |
by blueflashlight (Pilgrim) on Jul 02, 2001 at 19:08 UTC | |
by voyager (Friar) on Jul 02, 2001 at 19:32 UTC | |
Re: should a module export FUNCTIONS or VARIABLES?
by VSarkiss (Monsignor) on Jul 02, 2001 at 19:31 UTC | |
by blueflashlight (Pilgrim) on Jul 02, 2001 at 22:31 UTC | |
Re: should a module export FUNCTIONS or VARIABLES?
by davorg (Chancellor) on Jul 02, 2001 at 19:33 UTC | |
by blueflashlight (Pilgrim) on Jul 02, 2001 at 22:26 UTC | |
Re: should a module export FUNCTIONS or VARIABLES?
by bikeNomad (Priest) on Jul 02, 2001 at 20:44 UTC |
Back to
Seekers of Perl Wisdom