The reason my is wrong has nothing to do with scope. It has everything to do with the kind of variable. my introduces a lexical variable - and lexical variables aren't part of a typeglob. local cannot be used to introduce variables, local acts on values. In this case, we'd either use our, or use vars.