in reply to Need Perl book advice

The Camel book, hands down.

Most of the experience I have in Perl comes from writing my own utilities. Surely there's some task you do all the time that you'd like to automate.

Here's one of mine: 'anew', a program that does nothing but create new files from a set of templates. You say something like 'anew example.tex' and it creates a new LaTeX file with all the appropriate headers and setup. Right now I can cut out a new perl program, perl module, C program, LaTeX document, HTML document, and even a new GNU Lilypond file--already set up for use as a jazz lead sheet (chords, lyrics, melody).

Now you could do the same basic thing with a shell script. But I added enough bells and whistles onto mine so it performs other useful functions:

You can say anew example.pmo and it will create a new file called example.pm, with the skeleton of an object oriented perl module already in place. Same thing with example.pmf (creates a functional example.pm module).

The program 'anew' itself responds to --help and --version. Handy in case you don't have to use it for a few weeks. The documentation is embedded right into the program using pod.

Whenever I need anew to learn a new type of file to create, all I need to do is 1.) make a template and store it in ~/share/anew and 2.) add one more entry to a hash in ~/bin/anew

So my recommendation would be: find a need. As you work on the program, you will find yourself inventing new features, and learning how to implement them.

$jPxu=q?@jPxu?;$jPxu^=q?Whats?^q?UpDoc?;print$jPxu;

Replies are listed 'Best First'.
Re^2: Need Perl book advice
by Anonymous Monk on Jul 31, 2004 at 15:01 UTC
    Your script "anew" sounds nice. care to post it? Also should why do you have to add a hash entry to anew? Should I not be able to just add a template to share/anew? share/anew/tex/ c/ pmf/ pmo/ .../ Then in each subdirectory have module for that template to handle building it. Of course there is alwasy the template toolkit.

      The odd thing about anew is, it was created with anew. Sounds like a chicken & egg sort of deal, but the hint to solve this riddle is in the version number ;-)

      And, of course, once you post code in public, you become acutely aware of the hacks . . . . but the important thing is, I wrote it and it works.

      $jPxu=q?@jPxu?;$jPxu^=q?Whats?^q?UpDoc?;print$jPxu;
        Seems to me that an equally important question would have been to ask for the templates too :).
Re^2: Need Perl book advice
by johnnywang (Priest) on Aug 01, 2004 at 02:50 UTC
    anew sounds great and very useful. I have something similar in emacs, just some simple eLisp. For example, I set up the basic perl module structure when creating a new perl module (use strict, "1;" in the last line, Exporter, @EXPORT_OK, etc.) I do the same thing for creating java classes, getter-setters, a singleton, a servlet, comments, etc., the possiblitites are limitless.
      One more thing, if the things you're creating are text based, a good module to look at is Template::Toolkit, you can create tempaltes for anything you want. Through Win32::OLE, you can even create Word/Excel templates (well, just a thought, I haven't had the need to do that.)