Other information you might find useful:
- If you include "\n" at the end of a message passed to the "die" or "warn" function, perl will not include "at {scriptname} line {N}" after the given message. That extra information only gets added to STDERR output when the string passed to die or warn does not end with "\n".
- You really should take a look at Pod::Usage -- I think it's one of the "core" modules (comes with perl); the examples in its man page should give you a nice idiom you'll want to use over and over.
- Pod::Usage works very well in combination with Getopt::Long, which is also a core module, and also well worth getting acquainted with, if you haven't used it yet.
Before I got hooked on Pod::Usage, my default template for command-line perl scripts included a line like:
my $Usage = "Usage: $0 \n";
and I would always put option flags, file args, etc, into that string, making it multi-line where appropriate, and if my arg checking indicated a need to give up (e.g. Getopt::Long returned false or some ad-hoc condition failed) that would lead to
die $Usage;
But Pod::Usage is better, especially if you are in the (very good) habit of providing a decent POD man page in your command-line scripts, and you want to make it easy for users to see the man page.
With my old habit, I usually regretted having to repeat the content of my "$Usage" variable in the "SYNOPSIS" section of POD. With Pod::Usage, I just have the SYNOPSIS section in POD (no redundant "$Usage" variable).
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.