in reply to Re^4: Need Perl book advice
in thread Need Perl book advice
I know, but posting that much code at once, I felt sort of like the guy who's asked to do a wedding toast and goes on with a speech for half an hour. Here's two of the templates (out of eight, so there is a quantity of mercy here). The point would be to make your own, according to your own needs.
First, the simplest perl program that implements the standard --help and --version options: anewmain.pl. (Notice I'm a firm believer in pod.)
#!/usr/local/bin/perl -w FILENAME use warnings; use strict; use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1; use Pod::Usage; # ======================================================== SETUP my $VERSION = v1.0.0; my %options; getopts('h', \%options); HELP_MESSAGE() if $options{'h'}; # ========================================================= MAIN print "ok"; # ========================================================= SUBS sub HELP_MESSAGE { pod2usage ( { -exit_status => 0, -verbose_level => 1 } ); } sub VERSION_MESSAGE { return 1 if (lc $ARGV[0] eq "--help"); print "This program is $0, "; printf "version %vd\n", $VERSION; printf "(Using Perl v%vd)", $^V; exit 0; } __END__ =head1 NAME FILENAME =head1 SYNOPSIS A one line description, possibly command syntax. =head1 STATUS Version information (program and Perl). =head1 DEPENDENCIES Any special CPAN module dependencies go here. =head1 DESCRIPTION The bulk of the documentation. =head1 OPTIONS =over 4 =item -h, --help Prints synopsis and options, then exits. =item --version Prints version information and exits. =back =head1 EXAMPLES text =head1 TO DO text =head1 BUGS text =head1 SEE ALSO text =head1 AUTHOR Bruce H. McCosar. =head1 COPYRIGHT Copyright %YEAR% by Bruce H. McCosar. All Rights Reserved. This program is free software. You may copy or distribute it under the same terms as Perl itself.
Second, in case any of you have ever seen GNU Lilypond, it is a cool music typesetting program. Although it isn't Perl, I had to do a lot of language learning before I could produce good copy with it. I'm proud of the result (template.ly). The syntax is similar to LaTeX:
% begin FILENAME \version "2.1.0" \header { title = "Title" composer = "Composer" } % components comp = \chords %{ \transpose c c %} { b1:m7.5- e:7 a:m6 a:m6 d1:m7 g:7 c:maj7 c:maj7 } melody = \notes %{ \transpose c c %} \relative c' { \key c \major \clef treble \time 4/4 d'1~ d c~ c \break f1~ f e~ e } words = \lyrics { tem -- plate tem -- plate } % integration \score { << \context ChordNames { \property ChordNames.chordChanges = ##t \comp } \addlyrics \context Staff = one { \property Staff.autoBeaming = ##t \property Staff.automaticMelismata = ##t \melody } \context Lyrics \words >> \paper { papersize = "letter" indent = 0 interscoreline = 0 } } % end FILENAME
And there you go; 'anew' can be adapted as stated in the original article, according to your needs.
|
|---|