in reply to Is there a problem with using barewords as filehandles ?
My understanding is that the problem is with the lack of restricted scope. Bareword filehandles are essentially globalpackage scoped (thanks, LanX) so your RD could easily stomp on someone else's RD in a module which your code usesthe same package and vice-versa. These possibilities for action-at-a-distance are the downside.
Is there some official perl documentation about any such issue ?
Not that I'm aware of. There's an oblique mention in the FAQ which says "Since you want to be a good programmer, you probably want to use a lexical filehandle" but makes no mention of why good programmers want to use lexical filehandles.
Update: Just found this very interesting counterpoint where luminaries such as brian_d_foy and merlyn argue in favour of keeping them (almost a decade ago). The last point about strict is also interesting in the light of recent events.
See also:
- The same bareword could be used elsewhere as a non-filehandle
- The rationale in Modern Perl
- A review of PBP which praises Damian's rationale without quoting it, alas.
- "open" Best Practices
- lexical vs. local file handles
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Is there a problem with using barewords as filehandles ?
by LanX (Saint) on Jul 01, 2020 at 10:57 UTC | |
by hippo (Bishop) on Jul 01, 2020 at 11:34 UTC | |
by ikegami (Patriarch) on Jul 19, 2020 at 11:59 UTC | |
by LanX (Saint) on Jul 19, 2020 at 12:14 UTC | |
by ikegami (Patriarch) on Jul 19, 2020 at 23:23 UTC | |
Re^2: Is there a problem with using barewords as filehandles ?
by eyepopslikeamosquito (Archbishop) on Jul 02, 2020 at 10:32 UTC | |
Re^2: Is there a problem with using barewords as filehandles ?
by ForgotPasswordAgain (Priest) on Jul 01, 2020 at 14:19 UTC | |
by LanX (Saint) on Jul 01, 2020 at 15:23 UTC |