Basic HTML version of Foils prepared Sept 20 97

Foil 29 Some Remarks about Subroutines - VI -- Separating Arguments

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 popmany { # See previous foil for use
2 my $aref; # A local scalar to hold pointer to array
3 my @retlist = (); # An array to hold returned list
4 # Pop last element in each input array:
5 foreach $aref ( @_ ) { # loop over arguments
  • # @$aref is global array pointed to in argument:
  • push(@retlist, pop(@$aref) );
6 }
7 # @retlist holds last element of each array passed
8 return @retlist;
9 }

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