hogan@csl.sri.com (Emmett Hogan) (06/01/91)
Hi I am having a couple of strange problems writing a simple report formatter (actually a report re-formatter to reformat the quot report), and I was hoping you PERL gurus might be able to help. 1) I am using two formats, one for the data and the "top" format. My problem is that if I do the "write" to STDOUT, everything is fine and dandy, but if I do a write to a file, I lose the first line of data, but the headers print out just fine. 2) Is there any way to prompt the user for input, plus have the program accept data from STDIN? I know it's a long shot, but what I would like to be able to do is: % quot | quot-report.pl Detailed Report [y/n]? <---- this is a prompt from my program In C I believe I would be able to open /dev/tty for input, can I do this in PERL? Thanks in Advance, Emmett -- ------------------------------------------------------------------- Emmett Hogan Computer Science Lab, SRI International Inet: hogan@csl.sri.com UUCP: {ames, decwrl, pyramid, sun}!fernwood!hercules!hogan USMAIL: EL231, 333 Ravenswood Ave, Menlo Park, CA 94025 PacBell: (415)859-3232 (voice), (415)859-2844 (fax) ICBM: 37d 27' 14" North, 122d 10' 52" West -------------------------------------------------------------------
tchrist@convex.COM (Tom Christiansen) (06/01/91)
From the keyboard of hogan@csl.sri.com (Emmett Hogan): :1) I am using two formats, one for the data and the "top" format. My : problem is that if I do the "write" to STDOUT, everything is fine : and dandy, but if I do a write to a file, I lose the first line of : data, but the headers print out just fine. Well, it's a bit hard to know quite what's up without seeing the source, but here's a stab. Are you properly selecting the right format for the other filehandle? For example, if you have done this format STDOUT = . Then it will use this for write()s to STDOUT, but if you switch to another handle, you'll need to set $~ to the format you want (or else name the format the same as that filehandle). :2) Is there any way to prompt the user for input, plus have the : program accept data from STDIN? I know it's a long shot, but what : I would like to be able to do is: : : % quot | quot-report.pl : Detailed Report [y/n]? <---- this is a prompt from my program : : In C I believe I would be able to open /dev/tty for input, can I do : this in PERL? Sure, just say open(TTY, "</dev/tty") || die "can't open /dev/tty: $!, bailing out"; --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "So much mail, so little time."