new_perl
new_perl

Reputation: 7735

What's the difference between STDIN and tty at all?

Tt seems to be the same whether I read from STDIN and /dev/tty,

so what's the difference at all?

Upvotes: 7

Views: 3851

Answers (1)

Stuart Watt
Stuart Watt

Reputation: 5391

/dev/tty is the controlling terminal for the current process. STDIN is the current input. If you redirect, e.g.,

perl script.pl <myfile.txt

STDIN will now come from myfile.txt, but /dev/tty would still come from the controlling terminal. It's all UNIX, not Perl, and there is much more to it than that, but that's the difference in a nutshell.

Upvotes: 7

Related Questions