laziness, impatience, and hubris | |
PerlMonks |
Re^5: Summing numbers in a fileby haukex (Archbishop) |
on Jun 01, 2020 at 06:17 UTC ( [id://11117547]=note: print w/replies, xml ) | Need Help?? |
First of all, note that all of this is in the context of what advice to give wisdom seekers. You're of course free to code however you like. That recent discussion involved "pseudo-lexical" file handles using local. I know, but many of the issues discussed still apply. And again, I'll point out that lexical filehandles solve all of the issues discussed here. I'll also ask the same thing as I did in that thread: I've named some disadvantages, what are the advantages that you see to using bareword filehandles? bareword file handles are reasonable in top-level code. (Modules do not normally contain top-level code.) The issue is not where the code is, i.e. whether it's "top-level" or not, it's action at a distance: a module may load another module that may load another module that may do something that clashes with a global the main code is using; those issues are not fun to debug. While the typo-catching features of use strict are helpful, you should not be using file handle names that are that easily confused in the first place. Sorry, but how is this argument different from "you don't need strict as long as you don't make typos"? Let me pull together several quotes from your replies in this subthread and add some emphasis to try to point out a theme:
Of course the normal convention is that everyone should write correct, bug-free code! ;-P Update: Just to be clear, the theme I see here is that you seem to be placing a lot of expectations on people to write correct code, when simply using lexical filehandles easily provides protection from the issues. /Update (By the way, Prototypes are often discouraged now except when used to change how subroutine calls are parsed.) Speaking of your other post: In a case where the file handle is intended to be an "environment parameter" to a subroutine, global file handles are the only option Sorry, but I don't get this - what do you mean with an "environment parameter"? And I very strongly disagree with "only option".
In Section
Seekers of Perl Wisdom
|
|