There's no function in there, so it supports what I guessed: It's got nothing to do with closures.
Another danger of the non-list approach is that the function sees the lexical context of its definition and can accidentally use something from there
No, they don't accidentally capture anything. Closures only capture the variables they need.
The following shows that $x wasn't captured even though it was visible to the capture.
use strict; use warnings; printf "x=%s\n", do { my $x = 2; sub { $x } }->() // 'undef'; printf "x=%s\n", do { my $x = 2; sub { eval '$x' } }->() // 'undef';
x=2 Variable "$x" is not available at (eval 1) line 2. x=undef
The warning is new, but the behaviour is ancient.
In reply to Re^8: what is difference between calling the function in Perl/Tk in the following ways
by ikegami
in thread what is difference between calling the function in Perl/Tk in the following ways
by kiruthika.bkite
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |