Basic HTML version of Foils prepared Sept 20 97

Foil 14 Soft Symbol Table References - II

From Perl5 and Advanced Perl4 Features Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


We can more miraculously set
$name="foo"; # define an innocent ascii string
${$name} = 6; # sets $foo=6 as though $name was a symbolic reference
$$name = 6; # also sets $foo=6
$name->[0] = 4; # sets $foo[0] = 4
${$name x 2} = 6; # sets $foofoo = 6 ; # remember definition of x for strings
@$name = (); # sets @foo to null list while
&$name(arguments); # calls subroutine foo with given arguments!
use strict 'refs'; # FORBIDS symbolic references and above syntax will lead to error messages
*PI =\3.14159; # ensures that $PI is set in a way that you can not override it!
  • i.e. $PI = 3; # generates an error



© 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 Apr 5 1998