Basic HTML version of Foils prepared March 30 97

Foil 21 Arrays and Lists of Scalars(data) VI -- Undefined (Chapter 3 of Llama Book)

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


When variables are undefined or set to undefined as in
  • $a = $b ; # and $b has not been defined
They are given special value undef which typically behaves the same as null (character string) or zero (numeric) value
  • <STDIN> returns undef when End of File is hit
  • $fred =(0,1,2,3); $a = $fred[6]; # sets $a equal to undef
  • $fred = (0,1,2,3); $fred[6]=7; $a= $fred[5]; # leaves $a and $fred[4,5,6] undefined
$index = $#fred; # sets $index as index value of last entry in @fred
  • $a=@fred; $b=$#fred; # imply that $b=$a-1
Useful functions defined() and exists() will be discussed in Perl5 notes -- they allow precise tests on defined variables



© 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