in reply to Re^2: Unclear about 'our'
in thread Unclear about 'our'
The reason our appears to have little advantage over my is that you are misusing my.
In the modules and programs I've written, I typically declare a bunch of 'my' variables up top, outside of any blocks, which subsequent subroutines can freely access.....
Although this 'works', it is considered poor practice. It defeats the advantage of using my with use strict. Lexical (my) variables should be declared in the smallest possible scope. Accidental usage elsewhere will be detected at compile time. It is often useful to declare the same name in different scopes. (They actually refer to different variables). Both structured design and the newer object-oriented design discourage using subroutines that share a common pool of variables. Subroutines that do are much harder to test and debug than those that do not.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Unclear about 'our'
by ikegami (Patriarch) on Dec 30, 2022 at 14:56 UTC | |
|
Re^4: Unclear about 'our'
by ibm1620 (Hermit) on Dec 28, 2022 at 17:45 UTC | |
by haukex (Archbishop) on Dec 28, 2022 at 17:55 UTC | |
by ibm1620 (Hermit) on Dec 28, 2022 at 20:48 UTC | |
|
Re^4: Unclear about 'our'
by LanX (Saint) on Dec 28, 2022 at 17:07 UTC | |
by haukex (Archbishop) on Dec 28, 2022 at 17:47 UTC | |
by LanX (Saint) on Dec 28, 2022 at 18:45 UTC | |
by haukex (Archbishop) on Dec 29, 2022 at 08:58 UTC | |
by LanX (Saint) on Dec 29, 2022 at 11:04 UTC | |
|