Tt seems to be the same whether I read from STDIN
and /dev/tty
,
so what's the difference at all?
/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.
精彩评论