Syntactic Confectionery Delight | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
lexicals declared at file-scope are global variables Yes, you have a point, but: acting like they are somehow different No, they are in fact different: as I've said plenty of times now, bareword filehandles are not protected against typos and they clash with package and sub names, among other things. There is no remedy for this other than "being careful" (good luck in the long term) or using lexicals. On the other hand: the additional risk that file-scope lexicals can be shared across packages if multiple packages are defined in the same file While not wrong, this is only true under certain circumstances: if there are multiple packages in the same file, and those packages are in the same lexical scope, and the user has similarly named lexicals and makes a typo that happens to reference a previously declared lexical.
there really is almost no difference between [bareword filehandles] and lexical file handles — declaring a lexical at file-scope has almost exactly the same effect, and exactly the same effect if the convention of maintaining a 1:1 mapping between files and packages is followed Once again, no, and I find this insistence quite misleading. If you're going to recommend bareword filehandles, at least acknowledge the issues they have. In reply to Re^4: Is there a problem with using barewords as filehandles ?
by haukex
|
|