Basic HTML version of Foils prepared March 30 97

Foil 52 Functions or Subroutines - IV -- An Example
(Chapter 8 of the Llama Book)

From PERL4 Tutorial for CPS616 Computational Science for Information Age Course CPS616 -- February 1995. by Geoffrey C. Fox


sub bigger_than {
  • local($test,@values); # Create local variables for
    • test number and original list
  • ($test,@values) = @_; # Split argument list and give nicer names -- see previous foil for nicer notation!
  • local(@result); # A place to store and return result
  • foreach $val (@values) { # Step through
    • argument list
    • if( $val > $test ) { # Should we add this value
    • push(@result,$val); # add to result list
    • }
  • }
  • @result; # Required to specify what to be returned
} # Could be pedantic and write return @result



© 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