Chapter 11. How Do Subroutines Function?

How Do Subroutines Function?

Subroutines/Functions

In addition to the large number of Perl functions already available, you can create your own functions or subroutines. Some languages distinguish between the terms function and subroutine. Perl doesn’t. If you say “subroutine,” everyone will know you are talking about a “function,” and if you say “function,” everyone will know you are talking about a “subroutine.”[1] Technically, a function is a block of code that returns a value, whereas a subroutine is a block of code that performs some task, but doesn’t return anything. Perl subroutines and functions can do both, so we’ll use the two ...

Get Perl by Example, Fourth Edition 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.