modules should be using lexical file handles, except, for example, a logging module that opens the log file as a global handle in its package
Even there, a global filehandle is not necessary - a lexical declared in the module will do exactly the same job.
I suspect that there is some limit of human attentiveness, such that a small set of "watch these carefully" is workable, but as that set expands, the risk of typos increases.
Definitely - but this seems to be an argument for lexical filehandles rather than global ones.
... can sometimes be necessary to ... pass needed information to a callback procedure, although a combination of closures and function currying might work in most cases, at the expense of being even harder to debug.
I disagree with these two bits - I think the usage of globals can be avoided 99.9% of the time (or more) through proper API design (and yes, I make the same exception for existing legacy APIs), and also I disagree with it being harder to debug; issues arising from incorrectly used globals are IMHO much more annoying to debug. But again, the problem usually arises more in larger programs rather than shorter ones.
In reply to Re^7: Summing numbers in a file
by haukex
in thread Summing numbers in a file
by pvfki
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |