Closures
Learn about closures in Perl.
We'll cover the following
The computer science term higher-order functions refers to functions that manipulate other functions. Every time control flow enters a function, that function gets a new environment representing that invocation’s lexical scope. That applies equally well to anonymous functions. The implication is powerful, and closures show off this power.
Creating closures
A closure is a function that uses lexical variables from an outer scope. You’ve probably already created and used closures without realizing it:
Get hands-on with 1400+ tech skills courses.