Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Searching for perl utilities manager

by Courage (Parson)
on Aug 22, 2003 at 06:34 UTC ( [id://285692]=perlquestion: print w/replies, xml ) Need Help??

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

Dear all!

My problem is simple:
I wrote a number of utilities at work, and have a special script that could find them on our working environment.

However, a problem became larger when number of utilities became somewhat large -- I do not always remember utilities names, and of course even worse with parameters: almost every time I must look inside a file and check what should I pass.

My dream is an independent application (probably written using perlTk) that could manage my utilities and using GUI environment will allow me fill parameters and then execute it.
Most probably utility names and their parameters could be in some configuration file (it could be any text config file, YAML or anything else).
Even nicer if it could remember parameters from previous invocations.

Does anyone has a solution to this problem?
I suspect someone already wrote similar application.

Thanks in advance,
Courage, the Cowardly Dog

Replies are listed 'Best First'.
Re: Searching for perl utilities manager
by Abigail-II (Bishop) on Aug 22, 2003 at 08:03 UTC
    Uhm, this problem has been solved decades ago. Unix comes with a large set of utilities. One doesn't have to remember where a particular utility is located - that's why you have a PATH environment variable. One doesn't have to remember what the parameters of a utility are, that what manual pages and usage messages are for. One doesn't even have to remember which utility does what, that's what apropos is for - and that will even show you which Perl modules to use.

    $ apropos localtime localtime [ctime] (3) - transform date and time to broken-down tim +e or ASCII timegm (3) - inverses for gmtime and localtime Time::localtime (3pm) - by-name interface to Perl's built-in loc +altime() function timelocal [timegm] (3) - inverses for gmtime and localtime Time::tm (3pm) - internal object used by Time::gmtime and + Time::localtime $

    Abigail

Re: Searching for perl utilities manager
by AcidHawk (Vicar) on Aug 22, 2003 at 07:27 UTC

    I have found myself in the same situation. Often rather frustrating.. "I know I had a little tool to do this or but what was the syntax..?" etc. etc. The following are some simple tips that have helped me.

    I got some advise about this type of thing and since I have started to religiously do it I have not had this problem.

    Firstly -

      Comment your code thoroughly.. this took me a little longer to code anything when I started but now it is part of my process of getting anything done.. When I say thoroughly I mean at the start of you program a detailed description of what it does and what its inputs are and what it outputs. Also I find it helpfull to end with different error levels which I can check when my util has completed.. and you guessed it, I document these also.

      Then, for each subroutine I do a similar thing.. inputs, outputs and what is returned.

    Secondly -
      I build a html page with my utils in a table.. something like -

      UtilnameDescription and commandline args etc

      I started this type of thing ages ago and now all I have to do is keep adding to it..

    Thirdly -
      If my util takes command line args I also include a usage subroutine that gets launched when I have not included any args.

    So by way of a silly example my code would look something like -

Re: Searching for perl utilities manager
by liz (Monsignor) on Aug 22, 2003 at 07:37 UTC
    My take on this would be to:
    • document all of the scripts extensively with POD
    • create a CPAN distribution, use EXE_FILES in the call to ExtUtils::MakeMaker
    • create script that will run through MANIFEST or <scripts/*> to create an overview POD
    • install the distribution, you will have man files created from your POD!
    • optionally, run pod2html and you'll have HTML documentation as well

    That's what I would do. But then I'm used to creating CPAN distributions ;-)

    Liz

Re: Searching for perl utilities manager
by waswas-fng (Curate) on Aug 22, 2003 at 06:40 UTC
    Have a usage flag that shows you the standard inputs and flags and a man page -- unix can't be so wrong. =)

    -Waswas
      And a shell with history - to remember last used inputs and flags.
Re: Searching for perl utilities manager
by graff (Chancellor) on Aug 23, 2003 at 03:37 UTC
    I have my emacs set up so that every time I create a new file with ".perl" at the end of the file name, it automatically inserts the following into the editing buffer:
    #!/usr/bin/perl =head1 NAME =head1 SYNOPSIS =head1 DESCRIPTION =cut use strict; my $Usage = "$0 ";
    The very next thing that happens, after I open this new perl file, is I fill in the blanks. Then I start to write perl code -- and if it is a command-line tool that I'm writing (almost always the case), the first code that I write is "die $Usage if ..." (or "unless...") with suitable conditions checking the command line args. (Naturally, Getopts::Long or Getopts::Std is usually involved in that part.)

    I make a habit of never using "-?" as an actual command line option flag, so whenever I need to see the usage message, I run the script with "-?" as the sole option, which always causes the script to die and print $Usage. If that and the name of the script are not enough to remind me what the script is supposed to do (or what I'm supposed to do with it), the "$0" in the usage message always prints the full path to the script, and I can then paste that as an arg to "perldoc", to see the pod.

    Apart from that, a perl-tk pod browser is definitely a good idea -- I have one that I adapted from sample code that came with the Perl/Tk bundle, to show all the docs for the core distribution and for all installed modules. It just does a system() call to run "xterm -e perldoc chosen-page &" (which uses "less" as the pager), so I can have as many scrollable man pages as I want on the screen at once. I just now posted that here (Code->GUI Programming->PerlMan). (Heh, since I adapted that from someone else's code, my normal emacs init didn't happen there -- but it's a GUI, it doesn't have command line args, so who cares...)

    You could easily adapt that to all the perl programs in your arsenal, if these are all kept in places that are marked in your PATH environment variable, and if they all have a consistent file name pattern (e.g. *.pl or *.perl). Adding widgets for running command lines might be fun (or scary, depending on the roles you fill at your job).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://285692]
Approved by gjb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2024-04-19 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found