What is the -t used for in this Perl code

filehandle, perl

Solution

This code wants to assert that standard error is being redirected to a file. So running

perl the_script.pl

would trigger the `die` call, but

perl the_script.pl 2> error.log

would not.

Problem

I read in the perldoc that the -t file operator is used to decide if a filehandle is opened to a tty or not. Then i read what a tty was and from what i understand it's an old term for a terminal? My main question however is what this code is used for: ``` if(-t STDERR) { die "some warning/error message here" } ``` I guess i don't really understand what it means for a "filehandle to be opened to a tty". Does that mean that the particular output for that filehandle appears on the tty - or the terminal? Can tty refer to something besides the terminal?

Original source