Re: S04-related closure question

2008-09-22 Thread Patrick R. Michaud
On Sat, Jul 12, 2008 at 09:52:34PM -0500, Patrick R. Michaud wrote: > What would be the expected output from the following? > > my $a = foo(); > my $b; > > { > my $x = 1; > sub get_x() { return $x; } > sub foo() { return &get_x; } > $b = foo(); >

S04-related closure question

2008-07-12 Thread Patrick R. Michaud
What would be the expected output from the following? my $a = foo(); my $b; { my $x = 1; sub get_x() { return $x; } sub foo() { return &get_x; } $b = foo(); } my $c = foo(); say "a: ", $a(); say "b: ", $b(); say "c: ", $c(); As