Providing STDIN to a PIPEd call to perl
5 answers - 748 bytes -

I call a perl script from SAS using a pipe. The file on which the
script acts changes. Is there a way to provide the file name to the
script using STDIN on the command line? The SAS call looks like:
filename ABI pipe "perl C:/base.ps" ;
For now, I altered the script to read a text file containing the file
name, but this is wasteful. I appreciate any comments.
Thanks,
Kevin
Kevin Viel
Department of Genetics e-mail: kviel (AT) darwin (DOT) sfbr.org
Southwest Foundation phone: (210)258-9884
P Box 760549 fax: (210)258-9444
San Antonio, TX 78245-0549
Kevin Viel
PhD Candidate
Department of Epidemiology
Rollins School of Public Health
Emory University
Atlanta, GA 30322
No.1 | | 588 bytes |
| 
Kevin Viel wrote:
I call a perl script from SAS using a pipe. The file on which the
script acts changes. Is there a way to provide the file name to the
script using STDIN on the command line? The SAS call looks like:
filename ABI pipe "perl C:/base.ps" ;
For now, I altered the script to read a text file containing the file
name, but this is wasteful. I appreciate any comments.
I'm not exactly sure what you're asking but try this:
my $filename = <STDIN>;
chomp $filename;
@ARGV = ( $filename );
while(<>){
}
No.2 | | 987 bytes |
| 
Mr. Shawn H. Corey wrote:
Kevin Viel wrote:
>>I call a perl script from SAS using a pipe. The file on which the
>>script acts changes. Is there a way to provide the file name to the
>>script using STDIN on the command line? The SAS call looks like:
>>
>>filename ABI pipe "perl C:/base.ps" ;
>>
>>For now, I altered the script to read a text file containing the file
>>name, but this is wasteful. I appreciate any comments.
>>
I'm not exactly sure what you're asking but try this:
my $filename = <STDIN>;
chomp $filename;
@ARGV = ( $filename );
while(<>){
}
Shawn,
That should work, but I cannot use the keyboard to provide the STDIN.
Instead I was hoping for something like:
filename ABI pipe "perl C:/base.ps >file.ab1" ;
^^^^^^^^^
Thanks,
Kevin
No.3 | | 358 bytes |
| 
Kevin Viel wrote:
That should work, but I cannot use the keyboard to provide the STDIN.
Instead I was hoping for something like:
filename ABI pipe "perl C:/base.ps >file.ab1" ;
^^^^^^^^^
Thanks,
Kevin
How about?
my $filename = <>;
chomp $filename;
@ARGV = ( $filename );
while(<>){
}
No.4 | | 1779 bytes |
| 
Wed, Jul 05, 2006 at 11:31:55AM -0500, Kevin Viel wrote:
Mr. Shawn H. Corey wrote:
>Kevin Viel wrote:
>
>>I call a perl script from SAS using a pipe. The file on which the
>>script acts changes. Is there a way to provide the file name to the
>>script using STDIN on the command line? The SAS call looks like:
>>
>>filename ABI pipe "perl C:/base.ps" ;
>>
>>For now, I altered the script to read a text file containing the file
>>name, but this is wasteful. I appreciate any comments.
>>
>
>
>I'm not exactly sure what you're asking but try this:
>
>my $filename = <STDIN>;
>chomp $filename;
>@ARGV = ( $filename );
>while(<>){
>}
That should work, but I cannot use the keyboard to provide the STDIN.
Instead I was hoping for something like:
filename ABI pipe "perl C:/base.ps >file.ab1" ;
About the easiest way to get information from a file specified at the
command line, as far as I'm aware, is via while loop like so:
while(<>) {
do stuff;
}
If that's the beginning of your program, it will automatically grab the
contents of a file specified by name as a command line argument one line
at a time, and exit the while loop when EF is reached. The lines of
the file, as the example loop is written above, are on each iteration
assigned to the $_ scalar variable.
This is especially handy since, if you don't specify a filename, it
defaults back to taking input from the keyboard as though you had used
the STDIN filehandle.
No.5 | | 2455 bytes |
| 
Chad Perrin wrote:
Wed, Jul 05, 2006 at 11:31:55AM -0500, Kevin Viel wrote:
>>Mr. Shawn H. Corey wrote:
>>
Kevin Viel wrote:
I call a perl script from SAS using a pipe. The file on which the
script acts changes. Is there a way to provide the file name to the
script using STDIN on the command line? The SAS call looks like:
filename ABI pipe "perl C:/base.ps" ;
For now, I altered the script to read a text file containing the file
name, but this is wasteful. I appreciate any comments.
I'm not exactly sure what you're asking but try this:
my $filename = <STDIN>;
chomp $filename;
@ARGV = ( $filename );
while(<>){
}
>>
>That should work, but I cannot use the keyboard to provide the STDIN.
>Instead I was hoping for something like:
>>
>>filename ABI pipe "perl C:/base.ps >file.ab1" ;
About the easiest way to get information from a file specified at the
command line, as far as I'm aware, is via while loop like so:
while(<>) {
do stuff;
}
If that's the beginning of your program, it will automatically grab the
contents of a file specified by name as a command line argument one line
at a time, and exit the while loop when EF is reached. The lines of
the file, as the example loop is written above, are on each iteration
assigned to the $_ scalar variable.
This is especially handy since, if you don't specify a filename, it
defaults back to taking input from the keyboard as though you had used
the STDIN filehandle.
I apologize. I have not it sufficiently clear.
I have a SAS program that processes many thousands of files. However, I
found a perl module the greatly decreases my need for disk space. I use
a pipe in SAS to run perl. I only need to direct perl to the file of
interest.
I was hoping that I could include STDIN as a one-liner, perhaps by
issuing the -e option, since I am sending the call for perl using a SAS
pipe and not the command line.
I use SAS to supply the name of the file for me and to write this actual
line:
filename ABI pipe "perl C:/base.ps >file.ab1" ;
Thanks for all of the input,
Kevin