From 85d8b7d5cda435e10eacfec2d20f2936bdf7ca3a Mon Sep 17 00:00:00 2001 From: Michael G Schwern Date: Thu, 14 Jul 2005 12:10:51 -0700 Subject: [perl #36538] perlfunc/our contradicts itself From: "Michael G Schwern via RT" Message-ID: p4raw-id: //depot/perl@25148 --- pod/perlfunc.pod | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'pod/perlfunc.pod') diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 0235c3ec7f..447dad3fb1 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -3242,15 +3242,21 @@ See L and L for more about Unicode. =item our TYPE EXPR : ATTRS -An C declares the listed variables to be valid globals within -the enclosing block, file, or C. That is, it has the same -scoping rules as a "my" declaration, but does not create a local -variable. If more than one value is listed, the list must be placed -in parentheses. The C 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 declaration. In this -it differs from "use vars", which is package scoped.) +C associates a simple name with a package variable in the current +package for the remander of the lexical scope. The listed variables +are declared to be valid globals within the enclosing block, file, or +C. That is, it has the same scoping rules as a "my" +declaration, but does not create a local variable. When C is in effect, the C declaration lets you use the declared +global variable without qualifying it with a package name. (But only +within the lexical scope of the C declaration. In this it +differs from "use vars", which is package scoped.) + +If more than one value is listed, the list must be placed in +parentheses. + + our $foo; + our($bar, $baz); An C declaration declares a global variable that will be visible across its entire lexical scope, even across package boundaries. The @@ -3263,10 +3269,10 @@ behavior holds: $bar = 20; package Bar; - print $bar; # prints 20 + print $bar; # prints 20 as it refers to $Foo::bar Multiple C declarations in the same lexical scope are allowed -if they are in different packages. If they happened to be in the same +if they are in different packages. If they happen to be in the same package, Perl will emit warnings if you have asked for them. use warnings; -- cgit v1.2.1