But even if you put all the lines in different scopes (no warnings then), it's still the same variable when using our:
...as long as the alias refers to the same package variable. An our in an inner scope creates a new alias:
our $foo; { our $foo = 'foo'; say $foo; } { package Foo; our $foo = 'bar'; say $foo; } package main; say $foo; package Foo; say $foo; { package Foo; our $foo; say $foo; { package Bar; our $foo = 'quux'; say $foo; } say $foo; } { package Foo; say $foo; } __END__ foo bar foo foo bar quux bar foo
In reply to Re^5: Best practices - if any? (our)
by shmem
in thread Best practices - if any?
by AriSoft
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |