Subroutines are one of the fundamental concepts in programming. They help organize better-structured code, which is also easy to reuse. Perl 6 offers great support for subroutines and many interesting related features. In Perl 6, subroutines are often called subs.
We will cover the following topics in this chapter:
- Creating a subroutine
- Calling a subroutine
- Typed arguments
- Signature properties
- Passing arguments by value or by reference
- Operators as subroutines
- Nested subroutines
- References to subroutines
- Overloading subroutines and multiple dispatch
- Anonymous subroutines and lambdas
- Variable placeholders