Cases 1, 3 and 4 are almost identical wrt the scoping rules applied to the loop variable. Case 1 differs to the others only in that the lexical variable $v doesn't exist before the perl compiler sees the loop (so I guess that $v will be allocated in that scope's scratchpad.)
Case 2 is the only different one wrt to scoping - depending on whether $v has been declared outside the scope in which the foreach occurs at all, or declared as my, or as our:
See also Re^6: Hard syntax error or disambiguable parsing?.
In reply to Re^5: Hard syntax error or disambiguable parsing?
by shmem
in thread Hard syntax error or disambiguable parsing?
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |