in reply to Returning an error message when <STDIN> is not in use

I'm not at all sure what this has to do with STDIN, but it sounds like you just want to count the number of arguments passed to your program.

unless (@ARGV) { # error }

If I'm misunderstanding and you want to check whether STDIN is connected to the console, then you can use the -t file test operator.

if (-t STDIN) { # STDIN is connected to the console }
--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Returning an error message when <STDIN> is not in use
by jonadab (Parson) on Nov 09, 2006 at 16:02 UTC

    I'm not entirely certain, but I think he's referring to the magic behavior of the <> operator when you don't give it a filehandle. This is not STDIN as such, but it's similarly magic (insofar as it allows reading from a filehandle without opening it first), and it makes a certain amount of sense in conjunction with what he was saying about arguments.


    Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. You can just call me "Mister Sanity". Why, I've got so much sanity it's driving me crazy.
Re^2: Returning an error message when <STDIN> is not in use
by chinamox (Scribe) on Nov 10, 2006 at 05:43 UTC

    Thank you for your response. The unless (@ARGV) statement worked great!

    -mox