wouldn't it be better to check ARGV to see if arguments have been passed. if so use 
that as 
input. else read on STDIN.
/kk

On Tue, Aug 21, 2001 at 12:10:22PM -0800, Michael Fowler wrote:
> On Tue, Aug 21, 2001 at 03:44:05PM -0400, Andrew G.McArthur wrote:
> >  > squareroot 100 1000 25
> > 
> >  > cat numbers.list | squareroot
> > 
> >  > cat numbers.list | squareroot 25 144
> > 
> > I've had no problem with the second two examples, but the first waits 
> > for input from the STDIN.  How can I get my perl program to know that 
> > I'm not piping in data from the STDIN?
> 
> Your best bet is to check if STDIN is attached to a TTY, with the -t test. 
> If it is, it means the user hasn't redirected input into the script, either
> through a pipe or a file.
> 
> If you also allow the user to manually enter in numbers then this will
> become a problem.  At that point you could either set a timeout on your
> STDIN read, or implement your program differently so that it isn't so
> multi-talented.
> 
> 
> Michael
> --
> Administrator                      www.shoebox.net
> Programmer, System Administrator   www.gallanttech.com
> --
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to