Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Create and edit new scripts

by graff (Chancellor)
on Apr 25, 2006 at 01:11 UTC ( [id://545440]=note: print w/replies, xml ) Need Help??


in reply to Create and edit new scripts

It might be easier if you just have a "template.pl" file, copy that to the requested file name for a new script, and provide a command-line option for the user to indicate whether to fire up an editor on the new file. By using a command-line option (e.g. "-e" to start the editor), the code becomes a lot shorter and easier to read (no need for ALRM handling, reading from term, etc), and a lot easier to use.

And why not make the initial template something like this:

#!/usr/bin/perl =head1 NAME =head1 SYNOPSIS =head1 DESCRIPTION =head1 AUTHOR =cut use strict; use warnings;
That will make it clear that some amount of documentation should be included, which is usually a very good idea. (You can use the given file name and the user's name to initialize the first and last POD fields -- that would be very handy!)

Replies are listed 'Best First'.
Re^2: Create and edit new scripts
by johngg (Canon) on Apr 25, 2006 at 09:03 UTC
    Your suggestions make a lot of sense. Documentation is a very good thing that I'm not very good at. I will have to get to grips with POD but it's something I have been putting off.

    The use of a command-line option would indeed make things easier but I wanted to use ALRM handling just to learn how to do it. I wrote this some years ago and the first cut of the ALRM stuff was pretty crude. I tweaked it more recently with the countdown, again because I thought it would be interesting to learn. I'm not sure about your "... and a lot easier to use." There's not a lot of difference between

    % newscript -e fred

    and

    % newscript fred ... prompt ... y

    Thank you for the feedback,

    JohnGG

      Your suggestions make a lot of sense. Documentation is a very good thing that I'm not very good at. I will have to get to grips with POD but it's something I have been putting off.</blocckquote>

      I know this is mere proselytism, anyway in case you don't really get into POD you could give ROBODoc a try. It has a couple of advantages:

      • It sucks up much less space than POD;
      • It mixes up fine with code and comments (you can easily make documentation from your comments);
      • It works with any language I know of, so you can ROBODoc your Java, your html, your C and your PHP too.
      • ROBODoc can build a one-document digest from a whole code tree;
      • You can anyway generate HTML, RTF, PDF... from ROBODoc as well as POD;
      • Last, you can also generate POD with the ROBODoc to Pod translator script.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-03-29 14:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found