jlistf has asked for the wisdom of the Perl Monks concerning the following question:
i get the following warnings:use warnings; use strict; { our $y = 17; print "inner: $y\n"; } print "outer: $y\n";
but when i comment out the "use strict", the code runs and i get:Variable "$y" is not imported at tester.pl line 10. Global symbol "$y" requires explicit package name at tester.pl line 10 +.
so what happened? it seems like 'our' is similar to 'local' but it inputs the variable into the symbol table. this backs up merlyn's comment that its dynamically scoped. but it appears to stay defined outside of the block its declared in. is this a bug, or a special feature of 'our'?inner: 17 outer: 17
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: i thought i knew 'our'...
by autark (Friar) on Jul 24, 2000 at 20:39 UTC | |
by jlistf (Monk) on Jul 24, 2000 at 20:47 UTC | |
by autark (Friar) on Jul 24, 2000 at 21:03 UTC | |
|
Re: i thought i knew 'our'...
by mwp (Hermit) on Jul 25, 2000 at 22:27 UTC | |
|
Re: i thought i knew 'our'...
by monk (Scribe) on Jul 24, 2000 at 20:58 UTC | |
by autark (Friar) on Jul 24, 2000 at 21:11 UTC | |
by monk (Scribe) on Jul 24, 2000 at 21:17 UTC | |
|
RE: i thought i knew 'our'...
by jlistf (Monk) on Jul 24, 2000 at 20:23 UTC |