in reply to Re^3: Examples fo Where "our" is really needed
in thread Examples fo Where "our" is really needed
In Perl the word "our" does not declare a variable, but a private view of a public variable.
That's why I said "declare the same variable twice" and meant exactly the same as you do but with different words. Regardless how one choose to paint the issue I don't like to do the same thing twice if I don't have to or have a good reason not to. If I can't use regular ways of scoping access to a global then I can't, but if I can, as in my example above, I really prefer to not repeat myself. The day I refactor my code and/or mistype the name in one "repeated" our I might very well be hunting reasons for my uninitialized warnings instead of getting the help from the compiler I could've gotten. I'm unfortunately not just hypothesizing.
our has its uses, but I think that scattering out ours to tighten down the access scope for globals instead of create new scopes when that's possible/not inconvenient is an abuse rather than a use of our.
ihb
See perltoc if you don't know which perldoc to read!
|
|---|