In addition to all the body blocks, the whole if statement is a block of its own. Just like for and foreach loops.Note though that we very intentionally broke this in Perl 6. It's one of those places where you have to keep track of a list of exceptions in Perl 5, and all such lists are a design smell. (The right way to fix it was to fix the for/foreach syntax, not the if syntax. A loop variable should be lexical to its block by virtue of being a formal parameter to that block, not because it just happens to be mentioned in an exceptional syntax.)
In reply to Re^2: Duh. 'my' scope in if else blocks.
by TimToady
in thread Duh. 'my' scope in if else blocks.
by gam3
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |