I am writing an script which will allow a user with root access to rename a majordomo list and all associated files to a new name. I had gotten almost completely finished with the first try when I ran into a logic problem(moving a file to a new name and then trying to open it using the same ref doesn't really work, in case you were wondering). I sat up at this and thought for a moment: What's the best way to do this?

A given majordomo list has a multitude of files associated with it. Lets take a simple example: mylist.

The files for mylist are these:
/path/to/lists/mylist
/path/to/lists/mylist.config
/path/to/lists/mylist.passwd
/path/to/lists/mylist.resend

/other/path/to/archives/mylist/mylist.0101
/other/path/to/archives/mylist/mylist.NNNN


Along with the files for the list itself the script also needs to change the entries in /etc/aliases. Many of the listfiles themselves also have the listname inside of them. resend for example contains the listname to allow for proper addressing of incoming and outgoing mail messages.

My original script was this: a sub to change the filenames, a sub to move and rename the archives(and their directory), and a sub to change the aliases file, and one last one to modify the contents of files.

My question is this: Should I make the script as exact as possible in the subroutines and what they do or should I spend time making the subroutines very generic and do most of the logical work in the main routine (eg finding the list of files, sending them off to the modify routine then to the rename routine, etc).

I've never taken any programming classes but, rather ironically, my job has come to include a good bit of it. I suppose this is pretty basic concept. My thinking is the latter is prefered as it would allow you to much more easily re-use code and thus bring the overall amount of necessary programming down...

And hey, if anyone has suggestions as to a good way of structure thing as a whole or nifty way to do certain tasks ("renaming" a directory is still elluding me, I can only think to mkdir, move files, and then rmdir), please chime in...

Thanks

_____________________
mjn

2001-05-14 Edit by Corion : Changed title to be more descriptive.


In reply to Script design: Complexity/generalisation vs. simplicity/specialization (was: Majordomo Utility...) by mjn

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.