Paul Lalli wrote:
'our', like 'my', is lexically scoped. Its effects are terminated when the innermost enclosing block ends. So if you're using the same package variable in two different blocks, you have to use 'our' in each of them:
'our' is not lexically scoped; it is package scoped. Once you declare a variable using 'our' you may use it anywhere in the package. Think of it as an alias to the fully-qualified variable. A variable declare via 'our' in one package is independent of a variable of the same name in another package. See `perldoc -f our` for more details. #!/usr/bin/perl use strict; use warnings; package Foo; our $bar = 'Foo\'s bar'; # $bar is an alias to $Foo::bar print "$bar\n"; sub bar { print "Foo::bar sub: $bar\n"; } package main; our $bar = 'main\'s bar'; # $bar is an alias to $main::bar or $::bar; print "$bar\n"; print "$Foo::bar\n"; print "$main::bar\n"; print "$::bar\n"; Foo::bar(); __END__ -- Just my 0.00000002 million dollars worth, Shawn "For the things we have to learn before we can do them, we learn by doing them." Aristotle "If you think Terrans are comprehensible, you don't understand them." Great Fang Talphon -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/