Thanks for the compliments on my help message text. I do try to be clear.

You may have a point, re: your replacement code, with the exception that eliminating the subroutine definition for HELP_MESSAGE() would cause the script to fail to produce the contents of $help when invoked with the --help option. Thus, my two explicit conditional invocations of HELP_MESSAGE() should probably be replaced as you indicated, though I'd keep the subroutine. New code:

die $help unless $ARGV[1]; map { /^-?\d+$/ or die "Invalid input $_\n" } @ARGV; # . . . and later . . . sub HELP_MESSAGE { print $help; }

If I don't keep that subroutine in there, the --help option causes the following output to be produced:

/home/ren/bin/ies version 1.0 calling Getopt::Std::getopts (version 1. +05), running under Perl version 5.8.8. Usage: series [-OPTIONS [-MORE_OPTIONS]] [--] [PROGRAM_ARG1 ...] The following single-character options are accepted: Boolean (without arguments): -s Options may be merged together. -- stops processing of options.

edit: johngg pointed out the "unless" bug above, where unless @ARGV should read unless defined @ARGV instead.

print substr("Just another Perl hacker", 0, -2);
- apotheon
CopyWrite Chad Perrin


In reply to Re^4: a simple exercise in readability by apotheon
in thread a simple exercise in readability by apotheon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.