Basic HTML version of Foils prepared April 16,1996

Foil 27 Some Remarks about Subroutines - IV -- Call by Reference

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


sub doublearray {
  • my(*arraypointer) = @_;
  • foreach $elem (@arraypointer) {
    • $elem *= 2;
  • }
} # End routine to double elements of any array
# Suppose @foo and @bar are arrays
doublearray(*foo); # doubles elements of @foo
doublearray(*bar); # doubles elements of @bar



© 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