Basic HTML version of Foils prepared Sept 20 97

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

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 sub doublearray {
2 my(*arraypointer) = @_;
3 foreach $elem (@arraypointer) {
  • $elem *= 2;
4 }
5 } # End routine to double elements of an array
6 # Suppose @foo and @bar are arrays:
7 doublearray(*foo); # doubles elements of @foo
8 doublearray(*bar); # doubles elements of @bar

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