Do you know where your variables are? | |
PerlMonks |
Re: please review my first moduleby VSarkiss (Monsignor) |
on Jul 01, 2001 at 21:56 UTC ( [id://93040]=note: print w/replies, xml ) | Need Help?? |
This may entail a lot of work for you, but you asked ;-) I would suggest implementing the interface as a tied hash. As others have pointed out in this thread, you're exporting many sub names by default. Since all these values are logically related, it makes sense (to me, anyway) to collect them into a single data structure. That is, your caller would do something like this: It may be less work than it appears; your module would only have to implement the "reading" functions of the hash, not the "writing" ones. Also, remember you can inherit from Tie::Hash to take care of a lot of the work. Another suggestion is to cache up the values from the various exernal calls. As it stands, every time I ask for the aix_version, for example, the code will fork and exec to retrieve the same value. But if you make some room in the modeul, you can save the returned values once and re-use them for the life of the program. (It's OK to save these values once since none of them can change without at least rebooting the machine.) Note that you can cache the values regardless of whether you use the tied-hash interface, but IMHO it would be nice to combine the two. HTH Update 7/2/01: Better link to man page courtesy of tye.
In Section
Seekers of Perl Wisdom
|
|