Packages or namespaces are not scopes! This week I've seen a few people mention that, but it's not true and I don't know where people ever see that. Scopes are either blocks of code or the file, which has an implicit scope around all of its contents. The package pragma is scoped, but any symbol table work is does is not.
The parts of the code where a variable is visible constitutes the scope of the variable. Lexical variables have a lexical scope and you've enumerated the lexical scopes in Perl (except that lexical scopes are subsets of those because they begin on the statement after the variable is declared). The scope for a(n unqualified) package variable is the package. This is not a lexical scope but it is a scope. local effects dynamic scope which is about the scope of the value rather than the variable (or, more precisely, of an instance of the variable). Dynamic scope is certainly not a lexical scope.
The scope of the effect of symbol table manipulations is usually the symbol table, that is, the package. The scope of the effect of a lexical pragma is a subset of the lexical scopes that you enumerated, one starting at the statement after the invocation of the pragma (just like for lexical variables).
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|