I have a program that I am writing that I need to accept input from
either STDIN (for file redirections or pipes) or from the command-line.
The program manipulates email addresses for our mail servers, so I
should have the option to do either 'email_add
[EMAIL PROTECTED]' or 'email_add < /path/to/file'.

I thought that an algorithm similar to this should work.

if (defined(@ARGV) {
        process the text from the command line here;
} elsif (@EmailList = <STDIN>) {
        process the text from STDIN here;
} else {
        print usage statement;
}

When I run the program without any input it sits at the command line
until I either kill it, or I pass it some input from STDIN (typing a ^D
(control + D) will make it continue its execution).  Is there any way
that I can test if there is information queued up in STDIN without
actually requiring that there be information there (or specifically I
believe that the test is looking for an EOF)?

Tim Donahue


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to