Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.jpl.nasa.gov (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: you still have to type something, silly user Message-ID: <1991Apr19.005205.20746@jpl-devvax.jpl.nasa.gov> Date: 19 Apr 91 00:52:05 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Distribution: comp Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 38 In article thoth@reef.cis.ufl.edu (Robert Forsman) writes: : : I have a program that maintains a database of files and their vital : stats (CRC, mtime, ctime, etc). When updating, it takes a list of : files from <> and when <> runs out it inquires if the user wants to : update the database on file. : But!, <> is empty. How do I reopen the tty for input. I have a : feeling that my problem is woefully underspecified, but take a stab at : it anyway. : : Yes, I'm probably doing things pretty goofy. I'll talk to my boss : who commissioned this project and tell him about these minor problems. : I'm reading files from <> and thus STDIN (the terminal) may still : have input, but I want to know the politically correct way to reopen : the terminal under perl anyway. A solution that works (a very fuzzy : term: "works") when STDIN still has input would be the best. As you say, a bit underspecified, but you can get at the terminal regardless of what STDIN is attached to by saying: open(TTY, "; You might have to get fancier if you want to write on the tty as well. Here's one way: open(ITTY, "/dev/tty"); select((select(OTTY), $| = 1)[0]); print OTTY "prompt: "; $ttyline = ; You can arrange to read and write the same filehandle, but you may have to turn around stdio between reads and writes with a seek. I should really make +> opens on special files do the double stdio stream trick like sockets do... Larry