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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.