Basic HTML version of Foils prepared March 30 97

Foil 49 Functions or Subroutines - I (Chapter 8 of the Llama Book)

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


1 Functions are defined by the sub construct
  • sub itsname {
    • statements;
    • expression defining returned result;
    • }
2 They are invoked by the & construct
  • $sum = &add; # a simple routine with no arguments
  • sub add {
    • $a1+$a2+$a3; # Sum three global variables returning this expression
    • }
3 Note & becomes optional in PERL5 -- see advanced foilset

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 Sat Sep 6 1997