Bowen, Bruce <mailto:[EMAIL PROTECTED]> wrote:
: If I "declare" my 'lexical variables' at the beginning of a : file, and then refer to the variable without the 'my ' in front : of it, does that change it back to a package variable or does : that create a new package variable? Once a variable is declared using 'my' it can never be also be a package variable. They can refer to each other in such a way that changing one seems to change the other, but they are not the same type of variable. Think of the two types of perl variables as an apple orchard and peach orchard. If we grow an apple tree it can never become a peach tree and there are no peachapple trees. :) In no case can you use 'my' on the same variable in the same scope. Well, you can, but the warnings module will throw a warning about masking an earlier declaration. If your not sure what scope is, read the article I mentioned earlier. http://perl.plover.com/FAQs/Namespaces.html Now, you should try to keep your variables in the smallest scope possible. That means do not declare all of them at the top of your script. In some programming languages this is encouraged. Not in perl. Trust me and don't do it like that. Having said that, there are sometimes reasons to place a variable at the top of a script. Configuration variables come to mind. While developing it is nice to have a configuration hash at the top of the script. In production, we would probably add a configuration or serialization module and place that information in another file. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>