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.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to