Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

Recently I bought "Object Oriented Perl" written by Damian Conway. I have to say that I found it a very good read indeed. In fact it inspired me to give OO a try myself. I had never written a module before. But I have written a lot of scripts, including some very large ones [1], so I figured Perl itself shouldn't be too much of a problem for this endeavour.

To fill in the need for a simple-to-use terminal-based menuing system at our organization I decided to write something that would make building menus an easy task [2]. I think I have achieved this, but before submitting it to CPAN (and possibly make a fool of myself) I'd appreciate it if other (more experienced) Perl hackers could take a look at it.

One of the things bothering me is the test script. Currently it only tests if the Carp and Term::ReadKey modules are available. Surely that isn't good enough, but I don't know what more to test for besides that.

Any suggestions to make this distribution archive suitable for putting on CPAN would be appreciated very much.

The tarball with the full distribution is available at http://huizen.dto.tudelft.nl/devries/files/Term-ANSIMenu-0.01.tar.gz

Originally I had the output of pod2text appended, but it made the post a bit too long. So I figured I'd ask first before doing that. Anyone object to such a posting?

Thanks in advance for your time.

[1] One of those is an elaborate LDAP equivalent to what analog does for HTTP logs. It includes some graphs that would make for a nice extension to the current GD::Graph offerings. That will be my second OO project }:-)

[2] I know about perlmenu, but that didn't fit our needs.

Replies are listed 'Best First'.
Re: [RFC] new module Term::ANSIMenu
by PodMaster (Abbot) on Apr 18, 2003 at 15:01 UTC
    For starters, i'd say just fix up the pod a little. You have 2/3 extremely long likes (due to whitespace), try to keep it around 80 characters.

    The 2nd thing you should do is add comprehensive tests, testing EVERYTHING. See Tie::PureDB for an example on how to structure that.

    The 3rd thing you should do is use vars instead of our, and remove use warnings;, that way your module works with older perls, but that's entirely up to you (some people are forced to use old perls, so if they wanna user your module, they'll have to make the adjustments themselves).

    You might wanna consider inling your pod (=head2 function name ... =cut sub function ...), or even separating the pod into a separate document (ANSIMenu.pod), but that's also a preference thing (if you search for for inline pod you'll find some discussion of this).


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
    ** The Third rule of perl club is a statement of fact: pod is sexy.

      Hi PodMaster

      I have improved the pod and added some 76 tests. Everything that is not interactive and does not print to STDOUT directly is tested now. Thanks for the nudge in the right direction. The new version is available here

      I had to change the destructor though. It cleared the screen which is annoying during/after the tests, so I made it optional. Well, more freedom to the user is always a good thing anyway...

      There's one problem left (I think). The constructor does clear the screen too and I am reluctant to make that optional as I have no reliable way of getting the current position of the cursor (anyone know of something?), but it seems i'll have to. The test suite calls new() and thus clears the screen, which is not a good thing there. I need to think on a robust way of doing this...

      Thanks for your comments

      I know about the long lines. They come from an example that demonstrates automatic clipping if the line length exceeds the terminal width. As you can see from the rest of the pod I did try use propper line lengths. I'll probably have to adjust the "bad" lines considering your comment.

      I am a bit reluctant to remove use warnings, but I suppose I could use it while writing the code and comment it just before building the distribution. However to be honest I don't know if the module would work with older perls at all. As far as I can see it should work with 5 and up, but I am not sure about that. Can you tell me which version introduced "use warnings" as a better "-w"?

      I only use "our" for the definition of $VERSION. I thought it was appropriate for that. Am I mistaken? Everything else should be strictly private to the package itself.

      About the pod. What's the consensus around here? I am used to writing it after _END_ mostly because I feel it makes the code less cluttered. I always try to write the code itself as clear as possible, even at the cost of some performance, because most of the time others have to use it after I've written it and they might not be equally at home with Perl as me or the people frequenting this site. I don't have a problem with putting the attribute and method related parts next to the pieces of code they relate to. But this way it is all bundled together. To the users it shouldn't matter anyway as they'll probably only read it through pod2xxx or perldoc.

      I would like to test everything, but I just can't think of ways to test the menu's functionality. How do you verify a terminal supports ANSI sequences? Or really does return the keycodes I am using? I could use some hints on this one...

      Thanks for your comments. I am off now to start reading the page behind the link to Tie::PureDB now.

Re: [RFC] new module Term::ANSIMenu
by Limbic~Region (Chancellor) on Apr 18, 2003 at 14:39 UTC
    Anonymous Monk,
    I don't feel qualified to answer your question as I have only written a couple of modules for my personal use and only one that was OO. I do however want to say that I thought your post was well written. You are concerned about the right things (proper tests, re-inventing the wheel, documentation, etc). I would like to welcome you to the monastery (I have no idea how long you have been lurking) and invite you to create an account.

    Cheers - L~R

      I did just before posting, but somehow it was posted as coming from "Anonymous Monk". Probably had to do with me not accepting cookies. I changed that for this site now. So this should come through as being from "jadev".