Yes. Each block is a scope. Even bare curlies (without any flow control statements) make a block.
use strict;
{
my $foo = 2;
{
my $foo = 1; # masks outer $foo
my $bar = $foo;
print "foo is '$foo'\n"; # foo is '1'
}
print "foo is '$foo'\n"; # foo is '2'
print $bar; # # error, $bar not visible here
my $foo; # warning: $foo already declared
# as lexical in this scope.
}
print "foo = $foo\n"; # error, $foo not visible here
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|