Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: 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:

use AIX::Sysinfo; # depending on your decision to rename it tie %sysinfo, 'AIX::Sysinfo'; my $aix_hostname = $sysinfo{hostname}; # for example my $aix_version = $sysinfo{aix_version}; # for example
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 reply to Re: please review my first module by VSarkiss
in thread please review my first module by blueflashlight

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-28 18:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found