in reply to Lexical Scoping and Anonymous Subroutines Passed To Functions

I think my previous example was perhaps too involved. Here's something simpler that shows the same behavior:
#!/local/bin/perl -w use warnings; use strict; # Start of a big block - don't want to pollute { my $y = 222; my $x = 777; print "Initialized, what's the values?"; print " x = $x\n"; print " y = $y\n\n"; sub mysub { print " Start of subroutine\n"; print " what's x? (forget y for now)\n"; print " x = $x\n\n"; print " Going to child block\n"; print " let's inspect the variables again:\n"; my $sr = sub { print "y = $y\n\n"; print "x = $x\n\n"; }; &$sr; } } # Big Block mysub();

Replies are listed 'Best First'.
Re^2: Lexical Scoping and Anonymous Subroutines Passed To Functions
by dave_the_m (Monsignor) on Jun 15, 2007 at 22:07 UTC
    This bug is fixed in perl 5.9.0

    Dave.