Basic HTML version of Foils prepared March 30 97

Foil 12 Some Simple Scalar I/O Capabilities (Chapter 2 of Llama Book)

From PERL4 Tutorial for CPS616 Computational Science for Information Age Course CPS616 -- February 1995. by Geoffrey C. Fox


STDIN is a File Handle or Pointer and <STDIN> is a scalar representing next line from the input stream.
  • $line = <STDIN> sets variable $line to next line read from standard input.
Unusually, this line always includes terminating newline and so we have a special function to remove the last character of a string
chop($line); removes last character in $line and returns scalar string value of this character
  • $nl = chop($line) # should set $nl to "\n" and remove newline from $line
  • chop is replaced by chomp in Perl5
We can also print scalars with print $line;
print is more powerful and we learn about it later as argument can be a scalar but is normally a list or array



© 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 Sat Sep 6 1997