Returning a Value from a Subroutine

In the previous section, we concentrated on parameter issues. However, you can think of a function as a black box with inputs and outputs. The inputs are the parameters and the outputs are the value or values returned from the subroutine. In this section we concentrate on the values returned from a subroutine.

All Functions Return Something

In languages such as C, C++, and Java, a specific function either returns a value or it does not. In these languages, you need to explicitly specify a return type for those functions returning a value, and you also need to explicitly specify the type void for those functions that do not return a value.

In Perl, we would like to achieve the same behavior. However, as you ...

Get Programming PERL in the .NET Environment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.