Perl-Sensitive Sunglasses | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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:
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
In reply to Re: Closures clarification
by shmem
|
|