0: #!/usr/bin/perl
1:
2: use Pod::Text;
3:
4: &pods unless $name = shift;
5:
6: print "Greetings, $name. I'm quite pleased to meet you.\n";
7:
8: # I use the following little 6-line snippet in almost every script
9: # I write for public consumption. It allows me to use embedded
10: # POD documentation for the script as its usage statement,
11: # saving me the trouble of maintaining separate documentation
12: # and usage statements and allowing me to easily create HTML,
13: # LaTeX, PDF, or whatever kind of documentation for the script
14: # that I like.
15:
16: # It's so trivial, it almost seems silly to post it; however,
17: # I've found it to be quite useful.
18:
19: sub pods {
20:
21: my $message = shift;
22: print "\n$message\n\n" if $message;
23: open(POD,$0) || die "Cannot print help text for $0: $!";
24: Pod::Text->new()->parse_from_filehandle(\*POD);
25: close POD;
26: exit;
27:
28: } # end sub pods
29:
30: __END__
31:
32: =head1 DESCRIPTION
33:
34: hello.pl - A Perl script to print a greeting
35:
36: =head1 USAGE
37:
38: ./hello.pl name
39:
40: where C<name> is your name.
41:
42: =cut In reply to Self-documenting code by Starky
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |