in reply to Re^3: Syntax question about closures and Perl 'sort'
in thread Syntax question about closures and Perl 'sort'
And you will find that $x is not properly remembered, but $y is.sub create_closure { my $x = "x"; my $y = "y"; return sub { $y .= "y"; eval q{print "x: $x\ny: $y\n"}; }; } create_closure()->();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Syntax question about closures and Perl 'sort'
by jethro (Monsignor) on Apr 05, 2009 at 18:43 UTC |