in reply to Setting lexicals in a BEGIN block.
use warnings; use strict; { our $foo = 1; } print $foo; [download]
Variables declared with 'our' are lexically scoped:
Only their declaration is lexically scoped. The variable itself is a real global.
use strict; use warnings; { our $foo = "Hello, world!\n"; } { print our $foo; # prints: Hello, world! } [download]
use strict; use warnings; { my $foo = "Hello, world!\n"; } { print my $foo; # warns: Use of uninitialized value } [download]
- Yes, I reinvent wheels. - Spam: Visit eurotraQ.