Basic HTML version of Foils prepared Sept 20 97

Foil 34 Basic Input

From Tutorial on PERL Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


We've already seen how to read from standard input with
  • $line = <STDIN>; # return next line INCLUDING terminal newline
  • @file = <STDIN>; # return whole file with one line stored in each
    • # element of list @file
We can also easily access the command-line arguments of a PERL program. Suppose we invoke a PERL program called makePHD at the command line with
  • % makePHD file1 file2 file3
We will see later how to process these arguments using standard argument-handling conventions in UNIX
However, the Perl diamond operator <> returns the concatenation of these three files. For example,
  • @files = <>; # concatenate file arguments and store in @files



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Sep 21 1997