At 09:13 AM 7/15/02 -0500, David T-G wrote: >I *think* I understand this. > > - 'my' defines a var for only this block and does not export to > subroutines
Correct, although 'export' is the wrong term. This is why these are called 'lexical' variables; their scope is lexically defined (as in, from the 'my' statement through to the end of the current block or file, lexically - the range of characters defined by that scope). > - 'our' defines a var that is basically a global It is a lexical version of 'use vars'. It has the same *scope* as 'my' (lexical scope), but it refers to the *package* variable. Which of course can be referred to from anywhere if it is fully qualified. Personally I think that 'our' generates more confusion than help :-( > - 'local' defines a var that is like a 'my' but is visible to children > of the scope so that called subroutines can see it Correct, although you have missed a central point of 'local', namely that you can do it on a variable that is defined at an outer level and it makes a local copy of it (think stack). The declaration lasts as long as the lexical scope of the 'local' but the visibility of the variable is dynamic. And this is a package variable. Thus it is possible to refer to a lexical $x, a package $x, inner scope versions of the lexical $x, and localized versions of the package $x, all in the same program. (Great way to create obfuscated code.) Now you see why I don't teach package variables to my students until they get to object-oriented programming. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]