Basic HTML version of Foils prepared Sept 20 97

Foil 23 Arrays and Lists of Scalars VI -- Printing

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


The argument of print is a list (array)
  • print "Hello"," Rest", " of World";
  • @fred = ("Hello"," Rest", " of World");
  • print @fred; # equivalent to the previous print
One can input an entire file to a list where each entry of list is one line of file. For example,
  • @file = <STDIN>; # later we will see how to do for arbitrary files
As mentioned earlier, double-quoted strings perform variable interpolation for arrays as well as scalars
  • $string = "This is a full list @fred \n";
  • $string = "First value in list fred is $fred[0] \n";
  • Slices and variable indices can also be interpolated



© 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