Basic HTML version of Foils prepared April 16,1996

Foil 14 Soft Symbol Table References - II

From Perl5 and Advanced Perl4 Features Computational Science for Information Age Course CPS616 Material -- April 16,1996. by Geoffrey C. Fox


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 Sat Sep 6 1997