in reply to Closures clarification
why this is not a closure though ?
Because it is just a bare block. See perlsub and perlref, section Making References and the example there for how closures work.
in my eyes my $a is visible outside the {} many thanks
Outside the scope of that bare block, you see the global $a, which is special (see sort). How can you tell that it is the same as the $a declared with my inside the block? The inner is just declared and not used in any way. Here's how to check that:
use warnings; use strict; $a=1; { my $a = 5; } print $a; __END__ 1
One last thing - be sure that your example code actually compiles. Your first example doesn't, and in your second example there's a ';' missing at the end of $a=1
--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}
|
|---|