See Coping with Scoping.
Although that explains local, it unfortunately doesn't explain what's going on in the OP's example (that $1 and friends are dynamically scoped).
In reply to Re^2: A regex BR variable dead in following line/command
by haukex
in thread A regex BR variable dead in following line/command
by abdan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |