#!/usr/bin/perl use Pod::Text; &pods unless $name = shift; print "Greetings, $name. I'm quite pleased to meet you.\n"; # I use the following little 6-line snippet in almost every script # I write for public consumption. It allows me to use embedded # POD documentation for the script as its usage statement, # saving me the trouble of maintaining separate documentation # and usage statements and allowing me to easily create HTML, # LaTeX, PDF, or whatever kind of documentation for the script # that I like. # It's so trivial, it almost seems silly to post it; however, # I've found it to be quite useful. sub pods { my $message = shift; print "\n$message\n\n" if $message; open(POD,$0) || die "Cannot print help text for $0: $!"; Pod::Text->new()->parse_from_filehandle(\*POD); close POD; exit; } # end sub pods __END__ =head1 DESCRIPTION hello.pl - A Perl script to print a greeting =head1 USAGE ./hello.pl name where C is your name. =cut