Basic HTML version of Foils prepared April 16,1996

Foil 17 Anonymous Data Structures and Subroutines

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


Often one wishes to construct "unnamed" datastructures or subroutines where one keeps track of them by references as opposed to name
This is natural with subroutines which return either a datastructure or subroutine
$arrayref = [1, 2, ['a', 'b', 'c'] ]; # $arrayref is a hard reference to a 2D array with 5 defined elements
  • $arrayref->[2][1] will give value 'b' as will $$arrayref[2][1]
  • $arrayref->[0][0] is 1; $arrayref->[0][1] is undef;
$secretsub = sub { print "Support ECS\n" };
executed by &$secretsub;



© 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