How does the attached patch grab you?

-- 
David L Nicol
Aesop's fables, with text-sensitive advertising:
http://cronos.advenge.com/pc/aesop/start.html
--- perlfunc.pod.old	2005-07-15 15:08:38.125000000 -0500
+++ perlfunc.pod	2005-07-15 15:49:50.765625000 -0500
@@ -3198,19 +3198,21 @@
 
 =item our TYPE EXPR : ATTRS
 
-An C<our> declares the listed variables to be valid globals within
-the enclosing block, file, or C<eval>.  That is, it has the same
-scoping rules as a "my" declaration, but does not create a local
+Unlike C<my>, which both allocates storage for a variable and assigns
+a simple name to that storage for use within the current scope, C<our>
+associates a simple name with a package variable in the current package,
+for use within the current scope.  In other words, C<our> has the same
+scoping rules as C<my>, but does not necessarily create a 
 variable.  If more than one value is listed, the list must be placed
-in parentheses.  The C<our> declaration has no semantic effect unless
-"use strict vars" is in effect, in which case it lets you use the
-declared global variable without qualifying it with a package name.
-(But only within the lexical scope of the C<our> declaration.  In this
-it differs from "use vars", which is package scoped.)
-
-An C<our> declaration declares a global variable that will be visible
-across its entire lexical scope, even across package boundaries.  The
-package in which the variable is entered is determined at the point
+in parentheses.
+
+When C<use strict vars> is in effect, C<our> lets you use
+declared global variables without qualifying them with package names,
+within the lexical scope of the C<our> declaration.  In this
+way C<our> differs from C<use vars>, which is package scoped.
+
+The package in which a variable declared with C<our> lives
+is determined at the point
 of the declaration, not at the point of use.  This means the following
 behavior holds:
 
@@ -3219,11 +3221,15 @@
     $bar = 20;
 
     package Bar;
-    print $bar;		# prints 20
+    print $bar;		# prints 20, without looking up $bar in the symbol table
 
 Multiple C<our> declarations in the same lexical scope are allowed
 if they are in different packages.  If they happened to be in the same
-package, Perl will emit warnings if you have asked for them.
+package, Perl will emit warnings if you have asked for them, just like
+multiple C<my> declarations on the same name in the same scope.  Unlike
+a second C<my> declaration, which will assign the name in question to
+a fresh variable for the remainder of the scope, a second C<our> declaration
+in the same package, in the same scope, is merely redundant.
 
     use warnings;
     package Foo;
@@ -3234,7 +3240,7 @@
     our $bar = 30;	# declares $Bar::bar for rest of lexical scope
     print $bar;		# prints 30
 
-    our $bar;		# emits warning
+    our $bar;		# emits warning but has no other effect
 
 An C<our> declaration may also have a list of attributes associated
 with it.

Reply via email to