http://qs321.pair.com?node_id=22794


in reply to use vars

When declaring a variable with 'my', you say that it is lexical, that is, the variable is only visible within the scope that you declared it.

If you on the other hand 'use vars', you say that "in this package I want to use variable $foo without having to write out it's fully qualified name ($main::foo). $foo will not be lexically scoped, but will be a global (a package variable).

In perl 5.6 you may also use the keyword 'our' to declare variables as globals, but with a visibility scope equal to a lexical variable. A global with lexical scope ? That did sound strange :) Writing 'our $foo' inside a block or subrutine will make $foo a global - but you may refer to it as $foo _only_ within the lexical scope. You can still refer to $foo outside the scope, but then you will have to fully qualify it as $main::foo (or $my_package::foo)

Autark