That doesn't address the issue of accidentally running ./script.pl -i - without an input source for STDIN.

Sorry, but that doesn't make sense to me at all: if I told the program that I want it to take input from STDIN, then it doing exactly what I asked it to doesn't mean the program is "hanging" - maybe I really did want to type input in the console manually. In other words, telling the program explicitly "-i -" and then not giving it anything on STDIN is operator error, and IMHO not something the program should worry about.

Making '-i' required also would preclude allowing input exclusively from @ARGV.

Then get rid of -i entirely and do it like most other *NIXish programs, just take a list of input files from @ARGV, optionally requiring at least one filename if you don't want the default behavior of "empty @ARGV means STDIN" - forgetting the latter is a common and understandable thing in my experience.

I modeled the UI somewhat on wget/aria2c/(and very recently curl), ...

The fact that some programs get creative with their command line arguments doesn't mean you have to. Sorry, but I think you're overengineering here, and I really don't mean that as an insult - I've done that to myself plenty of times. Take a step back, think about what problem you're really trying to solve for, and whether the fix really needs to be such a complex thing as the root node is attempting. The *NIX way of command-line argument handling is a (quasi-)standard for a reason, part of that reason being that if all programs use similar command-line argument handling, it's easier for the operator to remember and avoid mistakes.


In reply to Re^5: Warn if STDIN pipe is missing or unwanted by haukex
in thread Warn if STDIN pipe is missing or unwanted by Anonymous Monk

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.