summaryrefslogtreecommitdiff
path: root/pod/perlfunc.pod
diff options
context:
space:
mode:
authorAristotle Pagaltzis <pagaltzis@gmx.de>2014-12-02 04:05:20 +0100
committerAristotle Pagaltzis <pagaltzis@gmx.de>2014-12-02 04:05:20 +0100
commitecafefb82337acf1046f535da14a6fc0293f70b5 (patch)
tree3c714f0e2edde2427082e216235a32463de85827 /pod/perlfunc.pod
parent94708f6d9bd9347f0cbb485f61d2f74215b62fd4 (diff)
downloadperl-ecafefb82337acf1046f535da14a6fc0293f70b5.tar.gz
perlfunc: document immediate stricture effect of "our"
Diffstat (limited to 'pod/perlfunc.pod')
-rw-r--r--pod/perlfunc.pod13
1 files changed, 12 insertions, 1 deletions
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 9347b60c23..5fe4b3d06c 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -4369,7 +4369,8 @@ existing variable: a package variable of the same name.
This means that when C<use strict 'vars'> is in effect, C<our> lets you use
a package variable without qualifying it with the package name, but only within
-the lexical scope of the C<our> declaration.
+the lexical scope of the C<our> declaration. This applies immediately--even
+within the same statement.
package Foo;
use strict;
@@ -4395,6 +4396,16 @@ package variables spring into existence when first used.
print $Foo::foo; # prints 23
+Because the variable becomes legal immediately under C<use strict 'vars'>, so
+long as there is no variable with that name is already in scope, you can then
+reference the package variable again even within the same statement.
+
+ package Foo;
+ use strict;
+
+ my $foo = $foo; # error, undeclared $foo on right-hand side
+ our $foo = $foo; # no errors
+
If more than one variable is listed, the list must be placed
in parentheses.