good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^3: Why callbacks?by Joost (Canon) |
on Mar 30, 2007 at 17:32 UTC ( [id://607539]=note: print w/replies, xml ) | Need Help?? |
Named subroutines never go out of scope; they're global - bound to a package just like global variables.
Anonymous subrefs can go out of scope, just like any other variable, but, just like any other variable, you can pass them around:
Also note that there are scoping issues with defining named closures within other subroutines (this probably has to do with named subroutines being global), while unnamed subroutines/closures will work as real lexical closures.
In Section
Seekers of Perl Wisdom
|
|