I first questioned its utility in
Why is 'our' good?. There are four basic problems that I know of with it. (I'm not counting the silly one that I pointed out above.)
- You have 2 packages in one file and didn't intend to use the variable from one package in the code for the other. This should be uncommon but not that uncommon.
- You have 2 files that access one package and you introduce synchronization issues. This is rarer than the first.
- A developer mistakenly tries to use our like you should use my. Now you have lots of room for a typo causing the variable accessed in one place to be different than the one in another, and strict.pm doesn't help.
- Using our is a gratuitous portability problem for people on Perl 5.005_05. Back when I first thought about this issue, that was a much bigger deal than it is today.
Its only advantage (in Perl 5) is that it involves slightly less typing. So while I consider it distinctly worse, it isn't really THAT bad.
As Larry pointed out in response to my node, its real purpose was a place to hang declarations about the variable in scope. For instance I believe one can say things like our Dog $spot is constant; and that has told Perl 6 that $spot must be something of type Dog, and in this lexical scope we are not allowed to change $spot. That's all functionality that couldn't be done with the old declaration.