Basic HTML version of Foils prepared Sept 20 97

Foil 55 Functions and Subroutines IV -- An Example

From Tutorial on PERL Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


1 sub bigger_than {
  • my ($test,@values); # Create local variables
  • ($test, @values) = @_; # Split argument list
  • local (@result); # A place to store result
  • foreach $val (@values) { # Step through arg list
    • if( $val > $test ) { # Should we add this value
    • push(@result, $val); # add to result list
    • }
  • }
  • @result; # Required to specify what to be returned
2 } # Could be pedantic and write return @result

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 Sep 21 1997