O'Reilly logo

Learning Perl, Second Edition by Randal L. Schwartz, Tom Christiansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.2. Invoking a User Function

You invoke a subroutine from within any expression by following the subroutine name with parentheses, as in:

say_hello();          # a simple expression
$a = 3 + say_hello(); # part of a larger expression
for ($x = start_value(); $x < end_value(); $x += increment()) {
    ...
}                     # invoke three subroutines to define values

A subroutine can invoke another subroutine, and that subroutine can in turn invoke another subroutine, and so on, until all available memory is filled with return addresses and partially computed expressions. (No mere 8 or 32 levels could satisfy a real programmer.)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required