O'Reilly logo

Pro Perl by Peter Wainwright

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

CHAPTER 7Subroutines

Subroutines are autonomous blocks of code that function like miniature programs. They can be executed from anywhere within a program, and because they are autonomous, calling them more than once will also reuse them.

There are two types of subroutine, named and anonymous. Most subroutines are of the named persuasion, called by writing their names literally into the source code. Anonymous subroutines do not have a name by which they can be called but are stored and accessed through a code reference. Since a code reference is a scalar value, it can be passed as a parameter to other subroutines and built-in functions like sort.

The use of named subroutines is syntactically the same as the use of Perl's own built-in functions. ...

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