On 3/14/11 Mon  Mar 14, 2011  1:49 PM, "Mark" <goo...@markginsburg.com>
scribbled:

> I need to detect if input has been to my script or not.
> 
> For example, I would like to differentiate between an invocation from
> the two lists below:
> 
> Examples where input is "provided":
> perl myscript.pl input.txt
> perl myscript.pl < input.txt
> executable_that_writes_to_sdtout | perl myscript.pl
> 
> Example of where no input is "provided":
> perl myscript.pl
> 

> I'm using Windows XP.
> 

The standard Unix function for determining this is isatty(in fd), where fd
is the file descriptor for the input/output stream. I don't know the
equivalent in Windows. However, there is the file test operator -t that
returns true if "Filehandle is opened to a tty", and the POSIX module
includes the isatty function. Try those.

perldoc -f -X
perldoc POSIX



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to