FAQ
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@darwin.sfbr.org
Southwest Foundation phone: (210)258-9884
P.O. 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

Search Discussions

  • Mr. Shawn H. Corey at Jul 5, 2006 at 4:19 pm

    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(<>){
    ...
    }


    --
    __END__

    Just my 0.00000002 million dollars worth,
    --- Shawn

    "For the things we have to learn before we can do them, we learn by
    doing them."
    Aristotle

    * Perl tutorials at http://perlmonks.org/?node=Tutorials
    * A searchable perldoc is at http://perldoc.perl.org/
  • Kevin Viel at Jul 5, 2006 at 4:32 pm

    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


    --
    Kevin Viel
    Department of Genetics kviel@darwin.sfbr.org
    Southwest Foundation for Biomedical Research phone: (210)258-9884
    P.O. 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
  • Mr. Shawn H. Corey at Jul 5, 2006 at 4:52 pm

    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(<>){
    ...
    }


    --
    __END__

    Just my 0.00000002 million dollars worth,
    --- Shawn

    "For the things we have to learn before we can do them, we learn by
    doing them."
    Aristotle

    * Perl tutorials at http://perlmonks.org/?node=Tutorials
    * A searchable perldoc is at http://perldoc.perl.org/
  • Chad Perrin at Jul 5, 2006 at 4:53 pm

    On 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 EOF 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.

    --
    CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
    unix virus: If you're using a unixlike OS, please forward
    this to 20 others and erase your system partition.
  • Kevin Viel at Jul 5, 2006 at 9:08 pm

    Chad Perrin wrote:
    On 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 EOF 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

    --
    Kevin Viel
    Department of Genetics kviel@darwin.sfbr.org
    Southwest Foundation for Biomedical Research phone: (210)258-9884
    P.O. 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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedJul 5, '06 at 3:46p
activeJul 5, '06 at 9:08p
posts6
users3
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase