Basic HTML version of Foils prepared Sept 20 97

Foil 22 Arrays and Lists of Scalars V -- Undefined

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


1 When variables are undefined or set to undefined as in
  • $a = $b ; # $b not defined
2 They are given special value undef which typically behaves the same as null (character string) or zero (numeric) value
  • <STDIN> returns undef when EOF is reached
  • @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, $fred[4], $fred[5], and $fred[6] undefined
3 $index = $#fred; # sets $index to index value of last entry in @fred
  • $a = @fred; $b = $#fred; # the expression $b == $a - 1 is true
4 Useful functions defined() and exists() are available

in Table To:


© 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