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


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

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