Re: What is the source of my input, file or STDIN?

2004-01-06 Thread drieux
On Jan 6, 2004, at 9:32 AM, [EMAIL PROTECTED] wrote: [..] So, 1. from within perl.script, how can one tell if the input stream is coming from STDIN or a file that was opened by <>? 2. If input stream is not coming from STDIN, but a file, how can one tell which file is the current file (assuming mul

Re: What is the source of my input, file or STDIN?

2004-01-06 Thread Jenda Krynicky
From: [EMAIL PROTECTED] > As I understand it, <> operator will open all items in @ARGV allowing > one to do a shell command line of > >perl.script file1 file2 file3 > > and inside perl.script you only need > > while (<>) { ... syntax to read all the files on the command line. > > > <> wi

Re: What is the source of my input, file or STDIN?

2004-01-06 Thread William.Ampeh
>So, 1. from within perl.script, how can one tell if the input stream is >coming from STDIN or a file that was opened by <>? Use select >2. If input stream is not coming from STDIN, but a file, how can one >tell which file is the current file (assuming multiple files were >specified on the co

RE: What is the source of my input, file or STDIN?

2004-01-06 Thread pgregory
t;STDIN" probably imply much more than I mean for them to convey. I hope this is more clear. And again, thanks for your help. - Paul -Original Message- From: drieux [mailto:[EMAIL PROTECTED] Sent: Tuesday, January 06, 2004 11:20 AM To: Perl Beginners Mailing List Subject: Re: Wh

RE: What is the source of my input, file or STDIN?

2004-01-06 Thread david
[EMAIL PROTECTED] wrote: > > Case 3. (this is the difficult case for me) the script is invoked > with no file and no pipe to it. I would like the script to > end quietly, such as >>test.input.source >> > > Instead, it waits for input. > >> test.input.source > no command line args - switching t

Re: What is the source of my input, file or STDIN?

2004-01-06 Thread Steve Grazzini
On Jan 6, 2004, at 3:17 PM, [EMAIL PROTECTED] wrote: Case 3. (this is the difficult case for me) the script is invoked with no file and no pipe to it. I would like the script to end quietly die usage() if @ARGV == 0 and -t; I didn't show you how to check for the pipe (-p) because this should pr

Re: What is the source of my input, file or STDIN?

2004-01-06 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote: > >So, 1. from within perl.script, how can one tell if the input stream is > >coming from STDIN or a file that was opened by <>? > > Use select > > >2. If input stream is not coming from STDIN, but a file, how can one > >tell which file is the current file (assuming multip

Re: What is the source of my input, file or STDIN?

2004-01-06 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote: > Thanks for the help drieux. > > I could have been more explicit in my question to have stated that > I want perl.script to exit quietly if there are no files on the > command line or if not invoked as the recipient of piped output. So what have you tried to adjust the c

Re: What is the source of my input, file or STDIN?

2004-01-07 Thread John W. Krahn
[EMAIL PROTECTED] wrote: > > As I understand it, <> operator will open all items in @ARGV allowing > one to do a shell command line of > >perl.script file1 file2 file3 > > and inside perl.script you only need > > while (<>) { ... syntax to read all the files on the command line. > > <> wil

Re: What is the source of my input, file or STDIN?

2004-01-07 Thread drieux
On Jan 6, 2004, at 1:07 PM, david wrote: [EMAIL PROTECTED] wrote: Case 3. (this is the difficult case for me) the script is invoked with no file and no pipe to it. I would like the script to end quietly, such as test.input.source Instead, it waits for input. test.input.source no command line a

Re: What is the source of my input, file or STDIN?

2004-01-07 Thread Steve Grazzini
On Jan 7, 2004, at 1:10 PM, drieux wrote: On Jan 6, 2004, at 12:53 PM, Steve Grazzini wrote: die usage() if @ARGV == 0 and -t; You might not want to test if there is a controlling terminal I want to test whether STDIN (the default argument for -t) is hooked up to the terminal (which is what -t te

Pipe and STDIN - Re: What is the source of my input, file or STDIN?

2004-01-07 Thread drieux
On Jan 6, 2004, at 12:17 PM, [EMAIL PROTECTED] wrote: [..] It just dawned on me that I may not be using the correct terminology since "pipe" and "STDIN" probably imply much more than I mean for them to convey. [..] This is a good angst point to raise. Technically STDIN|STDOUT|STDERR denote merely

-t and STDIN was Re: What is the source of my input, file or STDIN?

2004-01-07 Thread drieux
On Jan 7, 2004, at 10:37 AM, Steve Grazzini wrote: [..] I want to test whether STDIN (the default argument for -t) is hooked up to the terminal (which is what -t tells you) so that doesn't block waiting for user input. [..] I have absolutely no problem with the idea that one wants to use '-t' to

Re: -t and STDIN was Re: What is the source of my input, file or STDIN?

2004-01-07 Thread Steve Grazzini
On Jan 7, 2004, at 2:57 PM, drieux wrote: But simply because there is no controlling terminal does NOT mean that there is nothing on STDIN. Were you reading that code backwards? die usage() if @ARGV == 0 and -t; # if ((THERE ARE NO FILENAMES IN ARGV) && # (STDIN IS HOOKED UP TO A TERMIN

Re: -t and STDIN was Re: What is the source of my input, file or STDIN?

2004-01-07 Thread drieux
On Jan 7, 2004, at 12:42 PM, Steve Grazzini wrote: On Jan 7, 2004, at 2:57 PM, drieux wrote: But simply because there is no controlling terminal does NOT mean that there is nothing on STDIN. Were you reading that code backwards? die usage() if @ARGV == 0 and -t; # if ((THERE ARE NO FILENAMES