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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.