in reply to Re: Understanding difference between my and local variables.
in thread Understanding difference between my and local variables.

$a = 10; my $b = 20; # Can this be accessed inside the subroutine ? my ($c) = 30; # what is the meaning of bracket around variable name ? { # ... my ($p, @q, %r); local ($d, @e, %f); # (1) $b = 40; # does this change value of my $b ? # ... sub foo { # ... } # ... foo(17); # (2) bar($p,29); # (3) lbar($d, 31); # ... } # (4) # ... sub bar { my $d = 60; $b = 50; # ... }
Can we access the variable "b" declared as my variable at the beginning of the code, inside the subroutine ? Or is it out of scope ? We can not access my $d, declared inside sub bar(). Likewise, can a my $b variable, which is declared outside the bar() and at the beginning of the code, be accessed inside sub bar() ?

Thanks