use POSIX; close(STDIN); my $tty=POSIX::ctermid(); open(STDIN,"$tty");