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
|