my $x=5; BEGIN {$y=sub{my $r=sub{$x++;warn "sub: $x"};$r->()}} $y->(); #sub: 1 at temp.pl line 2. #deref sub that derefs sub, my before BEGIN, using scalars => autoviv BEGIN {$y=sub{my $r=sub{$x++;warn "sub: $x"};$r->()}} my $x=5; $y->(); #sub: 1 at temp.pl line 1. #deref sub that derefs sub, BEGIN before my, using scalars => autoviv my %x=(1=>5); BEGIN {$y=sub{my $r=sub{$x{1}++;warn "sub: $x{1}"};$r->()}} $y->(); #Modification of a read-only value attempted at temp.pl line 2. #deref sub that derefs sub, my before BEGIN, using hash => ERROR BEGIN {$y=sub{my $r=sub{$x{1}++;warn "sub: $x{1}"};$r->()}} my %x=(1=>5); $y->(); #sub: 1 at temp.pl line 1. #deref sub that derefs sub, BEGIN before my, using hash => autoviv my %x=(1=>5); BEGIN {$y=sub{$x{1}++;warn "sub: $x{1}";}} $y->(); #sub: 6 at temp.pl line 2. #deref sub, my before BEGIN, using hash => uses main's my variable BEGIN {$y=sub{$x{1}++;warn "sub: $x{1}";}} my %x=(1=>5); $y->(); #sub: 1 at temp.pl line 1. #deref sub, BEGIN before my, using hash => autoviv my $x=5; BEGIN {$y=sub{$x++;warn "sub: $x"}} $y->(); #sub: 6 at temp.pl line 2. #deref sub, my before BEGIN, using scalar => uses main's my variable BEGIN {$y=sub{$x++;warn "sub: $x"}} my $x=5; $y->(); #sub: 1 at temp.pl line 1. #deref sub, BEGIN before my, using scalar => autoviv