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

I've been wondering recently how others in the Monastary organize their scripts. Almost every script I write, I refer back to a previouly written script to refresh my mind on how I did things. The method I use for organizing my scripts is becoming increasingly unmanageable as I write more and more scripts for different tasks. So I'm wondering how others manage their scripts.

My attempt at organization looks something like below. I'm hoping to get some better ideas for keeping my scripts more organized. Whereby referring back to them isn't such a pain.

/perl/addresses /append /argv /arrays /backup ... ...

Thanks for any ideas,
Mike

Considered (jbrugger): Move to Discussion or meditation, not a perl (code) question
Unconsidered (holli): Enough keep votes (keep: 7 edit: 15 delete: 1)

Replies are listed 'Best First'.
Re: Script Organization || not
by kaif (Friar) on Jun 08, 2005 at 06:50 UTC

    I use the same organization as you do. I'm sure you already know this, but may I humbly suggest that you not make up acronyms to name your programs? Every once in a while, I browse through old programs and I see a directly named zf, look through it, run some programs, say "Wow! I wrote that?", and then proceed to wonder what the heck zf stands for. Oh, right! Zermelo-Fraenkel, of course, and that's an easy one, because sometimes I fail to decipher my own acronyms. Good fun.

Re: Script Organization || not
by monarch (Priest) on Jun 08, 2005 at 06:03 UTC
    This becomes fun after a few years, especially if you're deciding to CVS your repository.. (it is a little harder to re-arrange directories in CVS.. although isn't impossible).

    Personally I create a base ~/bin directory for storing my scripts.. why in bin? I can't really explain other than it's just evolved into a method that kinda works for me. Under that directory I have:

    /bin/script/perl /bin/script/bash
    and then under that I have my scripts, each in a subdirectory.

    I guess the best advice I can have is sit down and have a crack at your own method of organisation. Then after a year or so, review it! Good luck!

Re: Script Organization || not
by jbrugger (Parson) on Jun 08, 2005 at 04:37 UTC
    Hmm, most of the time i work on one application, and most of the scipts reside in cgi-bin.
    When i try to find an older piece of work, the unix command grep is my friend (using it on linux to find specific pieces of code).
    Your way of organizing seems fine to me, try grep "your search" -rli from the pwd /perl .

    "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.
Re: Script Organization || not
by crusty_collins (Friar) on Jun 08, 2005 at 04:44 UTC
    I usually am looking for a function that I wrote so... I tend to save parts of the scripts and organize pretty much like you do. For things I think are really important I save them to my database todo list that is backed up. Try ackerTodo for a handy easy to implement system.
Re: Script Organization || not
by TedPride (Priest) on Jun 08, 2005 at 17:06 UTC
    Well, you could put a description of each script in comments at the start:
    # Uses fisher-yates shuffle to randomize array
    Then run a script that takes keywords and spiders your scripts for possible matches to what you're looking for, returning a list of paths.
Re: Script Organization || not
by cajun (Chaplain) on Jun 10, 2005 at 00:58 UTC
    Thanks to all for the thoughts / suggestions.

    jbrugger - I use grep at times for searching for a previously written function. But I find in too many cases it returns far more than I'm looking for. For instance, if I'm looking for a script where I used 'format', then 'grep -rli format ~/perl' returns lots of false positives. Mainly from comments or whatever.

    crusty_collins - Nice little todo list (ackerTodo). I like that. But doesn't that add an item to my todo list? Keeping my todo list updated? Hahaha.

    monarch - I had thought about CVS at one time. I decided against it only because it appeared far more complex than I needed then (and perhaps now).

    kaif - Yes, acromyms could get confusing in a big hurry.

    TedPride - I comment most of my scripts heavily for my own benefit. Part of the learning curve. If I find a technique or something that is helpful to solving the problem at hand, I even include a link to the solution in the comments at the top of the script. I really like the idea of the spider. If I were to dream up some unique keywords to describe each script or function in it, that would be pretty cool.

    Intrepid - My scripts are not all for one sort of task either. They are for a variety of things. Maybe I should investigate CVS again.

Re: Script Organization || not
by Intrepid (Curate) on Jun 08, 2005 at 19:51 UTC

    One way to do it is to consider the revision control system that you're using part of the solution (instead of maybe part of the problem).

    I use CVS. My scripts are not all one kind of program, so they won't all belong in /cgi-bin/ or in ~/bin/ or any other particular location. On my setup there are scripts in all those places and more. Using CVS to do the version control means that the repository where the scripts are stored can be organized, and I try to use categories within the repository tree (subdir names) that relate to what the scripts are for. Then I try to maintain a careful $CVSROOT/CVSROOT/modules file (which is a manual administrative task if you don't employ some kind of 3rd-party system, if one exists).

    Using the modules file by doing  cvs co -c allows me to see what the names and locations (in the repository tree) of scripts are, which gives me a pretty good idea of what's in them. If I need to search more, I can use grep on the repository tree.

    -- 
    Now, in 2005: The 3 least meaningful terms in online jargon are:
        troll   flame   rant
    
    These used to actually mean something; but now they've been highjacked by the kind of inferior intellects who, when faced with a more erudite opponent who's employing superior arguments (or simply hanging in there with a disagreeable contention), merely abuse these terms, reducing them just another form of name-calling. ;-)