What do these do?
for 1,2 {
my $code = {
my $x;
BEGIN { $x = 42 }
$x;
};
say $code();
}
for 1,2 {
my $code = {
state $x;
BEGIN { $x = 42 } # mind you, not FIRST
$x++;
};
say $code();
say $code();
}
On Mon, Aug 14, 2006 at 16:01:47 +, Luke Palmer wrote:
What do these do?
Intuition based answers:
for 1,2 {
my $code = {
my $x;
BEGIN { $x = 42 }
$x;
};
say $code();
}
I think the closure would be emitted equivalently to my $x = 42, or
On Mon, Aug 14, 2006 at 04:01:47PM +, Luke Palmer wrote:
What do these do?
for 1,2 {
my $code = {
my $x;
BEGIN { $x = 42 }
$x;
};
say $code();
}
Assuming that variables are available immediately as
they are parsed and that BEGIN blocks