ehdonhon has asked for the wisdom of the Perl Monks concerning the following question:
I know that in most UNIX flavors, there must be a way to determine if the "standard" filehandles are actually standard, or if they are being piped somewhere. For example, when you run the 'ls' command, the default output formatting is different depending on wether you are outputting to the screen or piping the output to some other destination.
The 'more' command is a better example of what I'm doing. It knows wether you have specified a file name command line or wether you are piping its input via STDIN. When it displays the output, it will prompt you to continue after every page, unless you are piping the output into something else.
My question: How do I do this in Perl? I know one solution that some programs use is to require the user to specify a '-' filename whenever using STDIN/STDOUT, but I would like to make this unnecessary in my script.
Thanks in advance for any pointers.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: How do I find out if STDIN or STDOUT are attached to a pipe?
by merlyn (Sage) on Jun 21, 2002 at 17:02 UTC | |
|
Re: How do I find out if STDIN or STDOUT are attached to a pipe?
by broquaint (Abbot) on Jun 21, 2002 at 16:10 UTC | |
|
Re: How do I find out if STDIN or STDOUT are attached to a pipe?
by kjherron (Pilgrim) on Jun 21, 2002 at 20:47 UTC | |
|
Re: How do I find out if STDIN or STDOUT are attached to a pipe?
by grantm (Parson) on Jun 21, 2002 at 21:04 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |